diff --git a/Data/Graph/Analysis/Reporting/Pandoc.hs b/Data/Graph/Analysis/Reporting/Pandoc.hs index bc32485..207773f 100644 --- a/Data/Graph/Analysis/Reporting/Pandoc.hs +++ b/Data/Graph/Analysis/Reporting/Pandoc.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + {- | Module : Data.Graph.Analysis.Reporting.Pandoc Description : Graphalyze Types and Classes @@ -39,6 +41,8 @@ import Data.List (intersperse) import Data.Maybe (fromJust, isNothing) import System.Directory (removeDirectoryRecursive) import System.FilePath ((<.>), ()) +import Data.Text (Text(..)) +import qualified Data.Text as T -- ----------------------------------------------------------------------------- @@ -46,8 +50,14 @@ import System.FilePath ((<.>), ()) The actual exported writers. -} +#if MIN_VERSION_pandoc (2,0,0) +writeHtmlStringGeneric = writeHtml5String +#else +writeHtmlStringGeneric = writeHtmlString +#endif + pandocHtml :: PandocDocument -pandocHtml = pd { writer = writeHtmlString +pandocHtml = pd { writer = writeHtmlStringGeneric , extension = "html" , templateName = "html" , extGraphProps = Just VProps { grSize = DefaultSize @@ -84,7 +94,11 @@ pandocMarkdown = pd { writer = writeMarkdown -- | Definition of a Pandoc Document. Size measurements are in inches, -- and a 6:4 ratio is used for width:length. data PandocDocument = PD { -- | The Pandoc document style +#if MIN_VERSION_pandoc (2,0,0) + writer :: WriterOptions -> Pandoc -> PandocPure Text +#else writer :: WriterOptions -> Pandoc -> String +#endif -- | The file extension used , extension :: FilePath -- | Which template to get. @@ -144,23 +158,29 @@ defaultProcess = PP { secLevel = 1 -- | Create the document. createPandoc :: PandocDocument -> Document -> IO (Maybe FilePath) -createPandoc p d = do created <- tryCreateDirectory dir - -- If the first one fails, so will this one. - _ <- tryCreateDirectory $ dir gdir - if not created - then failDoc - else do d' <- addLegend dir gdir (graphProps p) d - elems <- multiElems pp $ content d' - case elems of - Just es -> do let es' = htmlAuthDt : es - pnd = Pandoc meta es' - doc = convert pnd - wr <- tryWrite doc - case wr of - (Right _) -> success - (Left _) -> failDoc - Nothing -> failDoc - where +createPandoc p d = do + created <- tryCreateDirectory dir + -- If the first one fails, so will this one. + _ <- tryCreateDirectory $ dir gdir + if not created + then failDoc + else do + d' <- addLegend dir gdir (graphProps p) d + elems <- multiElems pp $ content d' + case elems of + Just es -> do + let es' = htmlAuthDt : es + pnd = Pandoc meta es' +#if MIN_VERSION_pandoc (2,0,0) + let doc = runPure $ convert pnd +#else + doc <- tryWrite $ convert pnd +#endif + case doc of + (Right _) -> success + (Left _) -> failDoc + Nothing -> failDoc + where dir = rootDirectory d gdir = graphDirectory d auth = author d diff --git a/Graphalyze.cabal b/Graphalyze.cabal index fe16cc8..9616416 100644 --- a/Graphalyze.cabal +++ b/Graphalyze.cabal @@ -1,5 +1,5 @@ Name: Graphalyze -Version: 0.15.0.0 +Version: 0.15.0.1 Synopsis: Graph-Theoretic Analysis library. Description: A library to use graph theory to analyse the relationships inherent in discrete data. @@ -13,8 +13,7 @@ Extra-Source-Files: TODO Cabal-Version: >= 1.6 Build-Type: Simple -Tested-With: GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, - GHC == 7.10.2, GHC == 7.11.* +Tested-With: GHC == 8.4.2 Source-Repository head Type: git @@ -34,10 +33,10 @@ Library { filepath, process, random, - bktrees >= 0.2 && <0.4, - fgl == 5.5.*, - graphviz >= 2999.15 && < 2999.20, - pandoc == 1.19.*, + bktrees >= 0.2, + fgl >= 5.6, + graphviz >= 2999.20 , + pandoc >= 2.0 , text if flag(old-locale) {