BlogLiterately-diagrams 0.1.2.1 → 0.1.2.2
raw patch · 3 files changed
+27/−25 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- BlogLiterately-diagrams.cabal +3/−3
- CHANGES +4/−0
- src/Text/BlogLiterately/Diagrams.hs +20/−22
BlogLiterately-diagrams.cabal view
@@ -1,5 +1,5 @@ name: BlogLiterately-diagrams-version: 0.1.2.1+version: 0.1.2.2 synopsis: Include images in blog posts with inline diagrams code description: A plugin for @BlogLiterately@ (<http://hackage.haskell.org/package/BlogLiterately>) which turns inline diagrams code into images.@@ -62,8 +62,8 @@ cabal-version: >=1.10 source-repository head- type: darcs- location: http://hub.darcs.net/byorgey/BlogLiterately-diagrams+ type: git+ location: git://github.com/byorgey/BlogLiterately-diagrams.git library default-language: Haskell2010
CHANGES view
@@ -1,3 +1,7 @@+* 0.1.2.2: 29 August 2013++ - code cleanup, and move repository to github+ * 0.1.2.1: 8 August 2013 - allow diagrams-lib-0.7 and diagrams-cairo-0.7
src/Text/BlogLiterately/Diagrams.hs view
@@ -20,19 +20,16 @@ ( diagramsXF, diagramsInlineXF ) where -import Control.Arrow-import Data.List (isPrefixOf)-import qualified Data.Map as M-import Safe (headDef, readMay)+import Safe (readMay) import System.Directory (createDirectoryIfMissing) import System.FilePath import System.IO (hPutStrLn, stderr) import Diagrams.Backend.Cairo import Diagrams.Backend.Cairo.Internal-import Diagrams.Builder+import qualified Diagrams.Builder as DB import Diagrams.Prelude (R2, zeroV)-import Diagrams.TwoD.Size (SizeSpec2D (Dims), mkSizeSpec)+import Diagrams.TwoD.Size (mkSizeSpec) import Text.BlogLiterately import Text.Pandoc @@ -88,8 +85,9 @@ where (tag, src) = unTag s -extractDiaDef b = []+extractDiaDef _ = [] +diaDir :: FilePath diaDir = "diagrams" -- XXX make this configurable -- | Given some code with declarations, some attributes, and an@@ -99,9 +97,9 @@ -> String -- ^ Expression to render -> Attr -- ^ Code attributes -> IO (Either String FilePath)-renderDiagram decls expr attr@(ident, cls, fields) = do+renderDiagram decls expr attr@(_ident, _cls, fields) = do createDirectoryIfMissing True diaDir- res <- buildDiagram+ res <- DB.buildDiagram Cairo (zeroV :: R2) (CairoOptions "default.png" size PNG False)@@ -112,21 +110,21 @@ -- XXX can take this out once new diagrams-builder is released [] ["Diagrams.Backend.Cairo"]- (hashedRegenerate+ (DB.hashedRegenerate (\hash opts -> opts { cairoFileName = mkFile hash }) diaDir ) case res of- ParseErr err -> do+ DB.ParseErr err -> do let errStr = "\nParse error:\n" ++ err putErrLn errStr return (Left errStr)- InterpErr ierr -> do- let errStr = "\nInterpreter error:\n" ++ ppInterpError ierr+ DB.InterpErr ierr -> do+ let errStr = "\nInterpreter error:\n" ++ DB.ppInterpError ierr putErrLn errStr return (Left errStr)- Skipped hash -> return (Right $ mkFile hash)- OK hash (act,_) -> act >> return (Right $ mkFile hash)+ DB.Skipped hash -> return (Right $ mkFile hash)+ DB.OK hash (act,_) -> act >> return (Right $ mkFile hash) where size = mkSizeSpec@@ -136,18 +134,18 @@ renderBlockDiagram :: [String] -> Block -> IO Block renderBlockDiagram defs c@(CodeBlock attr@(_, cls, _) s)- | "dia-def" `elem` tags = return Null- | "dia" `elem` tags = do+ | "dia-def" `elem` classTags = return Null+ | "dia" `elem` classTags = do res <- renderDiagram (src : defs) "pad 1.1 dia" attr case res of- Left err -> return (CodeBlock attr (s ++ err))- Right file -> return $ Para [Image [] (file, "")]+ Left err -> return (CodeBlock attr (s ++ err))+ Right fileName -> return $ Para [Image [] (fileName, "")] | otherwise = return c where (tag, src) = unTag s- tags = (maybe id (:) tag) cls+ classTags = (maybe id (:) tag) cls renderBlockDiagram _ b = return b @@ -156,8 +154,8 @@ | "dia" `elem` cls = do res <- renderDiagram defs expr attr case res of- Left err -> return (Code attr (expr ++ err))- Right file -> return $ Image [] (file, "")+ Left err -> return (Code attr (expr ++ err))+ Right fileName -> return $ Image [] (fileName, "") | otherwise = return c renderInlineDiagram _ i = return i