packages feed

pandoc-plantuml-diagrams 0.1.0.4 → 0.1.1.0

raw patch · 12 files changed

+34/−15 lines, 12 filesdep +text

Dependencies added: text

Files

pandoc-plantuml-diagrams.cabal view
@@ -1,5 +1,5 @@ name:                pandoc-plantuml-diagrams-version:             0.1.0.4+version:             0.1.1.0 synopsis:            Render and insert PlantUML diagrams with Pandoc description:         PlantUML renders different types of UML diagrams.                      This filter invokes plantuml.jar (which must be present@@ -32,6 +32,7 @@                      , directory                      , utf8-string                      , bytestring+                     , text   hs-source-dirs:      src   default-language:    Haskell2010 @@ -68,6 +69,7 @@                      , bytestring                      , process                      , directory+                     , text  source-repository head   type:                git
src/Text/Pandoc/PlantUML/Filter.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE OverloadedStrings #-}  -- | -- Module    : Text.Pandoc.PlantUML.Filter@@ -8,6 +9,7 @@  import Text.Pandoc.JSON import Control.Monad+import qualified Data.Text as T  import Text.Pandoc.PlantUML.Filter.Types import Text.Pandoc.PlantUML.Filter.FileNameGenerator
src/Text/Pandoc/PlantUML/Filter/FileNameGenerator.hs view
@@ -14,13 +14,15 @@  import Data.Digest.Pure.SHA (sha1, showDigest) import Data.ByteString.Lazy.UTF8 (fromString)+import qualified Data.Text as T  import Text.Pandoc.PlantUML.Filter.Types  -- | Generates the Hash of a diagram source, and prefixes that. fileNameForSource :: DiagramSource -> ImageName fileNameForSource (DiagramSource source) = prefix ++ (hash source)-  where hash = showDigest . sha1 . fromString+  where+    hash = showDigest . sha1 . fromString . T.unpack  -- | The prefix to put before rendered images prefix :: String
src/Text/Pandoc/PlantUML/Filter/Formats.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE OverloadedStrings #-}  -- | Module : Text.Pandoc.PlantUML.Filter.Formats -- Determines the image type to be used for one particular@@ -10,6 +11,7 @@  import Text.Pandoc.Definition import Text.Pandoc.PlantUML.Filter.Types+import qualified Data.Text as T  -- | The image file type to be used for the given output format. -- EPS is used for latex outputs, as it provides lossless scalability
src/Text/Pandoc/PlantUML/Filter/IORender.hs view
@@ -7,13 +7,15 @@ import Data.ByteString.Lazy (hGetContents, hPut) import System.Process import System.Directory+import qualified Data.Text.IO as T+import qualified Data.Text    as T  import Text.Pandoc.PlantUML.Filter.Types  instance ImageIO IO where   renderImage imageFileName (DiagramSource source) = do     (Just hIn, Just hOut, _, _) <- createProcess $ plantUmlProcess imageFileName-    hPutStr hIn source+    T.hPutStr hIn source     hClose hIn     withImageFile $ pipe hOut     hClose hOut@@ -21,7 +23,7 @@   doesImageExist imageFileName = doesFileExist $ show imageFileName  plantUmlProcess :: ImageFileName -> CreateProcess-plantUmlProcess (ImageFileName _ fileType) = (proc "java" ["-jar", "plantuml.jar", "-pipe", "-t" ++ fileType])+plantUmlProcess (ImageFileName _ fileType) = (proc "java" ["-jar", "plantuml.jar", "-pipe", "-t" <> T.unpack fileType])   { std_in = CreatePipe, std_out = CreatePipe }  pipe :: Handle -> Handle -> IO ()
src/Text/Pandoc/PlantUML/Filter/OutputBlock.hs view
@@ -1,4 +1,4 @@-+{-# LANGUAGE OverloadedStrings #-} -- | Module : Text.Pandoc.PlantUML.Filter.OutputBlock -- Renders an image file name and some attributes into a Pandoc -- block, like so:@@ -13,16 +13,17 @@ import Text.Pandoc.JSON import Text.Pandoc.PlantUML.Filter.Types import Data.Maybe+import qualified Data.Text as T  -- | The result block, as specified in the module header. resultBlock :: ImageFileName -> Attr -> Block resultBlock imageFileName attr = Para $ map (\p -> p imageFileName attr) [imageTag, idTag]  imageTag :: ImageFileName -> Attr -> Inline-imageTag imageFileName attr    = Image nullAttr (altTagInline attr) (show imageFileName, "fig:")+imageTag imageFileName attr    = Image nullAttr (altTagInline attr) (T.pack $ show imageFileName, "fig:")  idTag :: ImageFileName -> Attr -> Inline-idTag _ (id, _, _)             = Str ("{#" ++ id ++ "}")+idTag _ (id, _, _)             = Str ("{#" <> id <> "}")  altTagInline :: Attr -> [Inline] altTagInline (_, _, keyValues)
src/Text/Pandoc/PlantUML/Filter/Types.hs view
@@ -7,14 +7,17 @@ -- module Text.Pandoc.PlantUML.Filter.Types where +import           Data.Text(Text)+import qualified Data.Text as T+ -- | The name of an image, without extension, usually a hash type ImageName = String  -- | The source of a diagram-newtype DiagramSource = DiagramSource String deriving (Eq, Show)+newtype DiagramSource = DiagramSource Text deriving (Eq, Show)  -- | An image format, e.g. "eps"-type ImageFormat = String+type ImageFormat = Text  -- | A filename of an image. It contains the basename (myawesomepicture) and -- the extension (jpg). It can be shown, which is basically@@ -24,7 +27,7 @@ -- | Show the image file name by joining basename and extension with -- a dot, yielding picture.jpg instance Show ImageFileName where-  show (ImageFileName name format) = name ++ "." ++ format+  show (ImageFileName name format) = name <> "." <> T.unpack format  -- | External impure actions are encapsulated in this monad. class Monad m => ImageIO m where
test/Text/Pandoc/PlantUML/Filter/FileNameGeneratorSpec.hs view
@@ -1,4 +1,4 @@-+{-# LANGUAGE OverloadedStrings #-}  module Text.Pandoc.PlantUML.Filter.FileNameGeneratorSpec where 
test/Text/Pandoc/PlantUML/Filter/FormatsSpec.hs view
@@ -1,15 +1,16 @@-+{-# LANGUAGE OverloadedStrings #-}  module Text.Pandoc.PlantUML.Filter.FormatsSpec where  import Test.Hspec import Text.Pandoc.Definition import Text.Pandoc.PlantUML.Filter.Formats+import Data.Text -formatFor :: String -> String+formatFor :: Text -> Text formatFor = imageFormatTypeFor . Format -shouldBeFormattedAs :: String -> String -> Expectation+shouldBeFormattedAs :: Text -> Text -> Expectation shouldBeFormattedAs docFormat imageFormat = (imageFormatTypeFor (Format docFormat)) `shouldBe` imageFormat  spec :: Spec
test/Text/Pandoc/PlantUML/Filter/OutputBlockSpec.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE OverloadedStrings #-}  module Text.Pandoc.PlantUML.Filter.OutputBlockSpec where 
test/Text/Pandoc/PlantUML/Filter/TypesSpec.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE OverloadedStrings #-}  module Text.Pandoc.PlantUML.Filter.TypesSpec where 
test/Text/Pandoc/PlantUML/FilterSpec.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE OverloadedStrings #-}  module Text.Pandoc.PlantUML.FilterSpec where @@ -9,6 +10,7 @@ import Text.Pandoc.PlantUML.Filter.FileNameGenerator import Text.Pandoc.PlantUML.Filter import Control.Monad.State.Lazy as S+import Data.Text  type FakeImageIO = S.State WorldInfo @@ -32,7 +34,7 @@     S.put st { renderedImages = ((show fileName), source) : oldImages}  -runProcessingIn :: WorldInfo -> String -> Block -> (Block, WorldInfo)+runProcessingIn :: WorldInfo -> Text -> Block -> (Block, WorldInfo) runProcessingIn wi format block = S.runState (processBlocks (Just (Format format)) block) wi