From b08997cd90c9eef58e5e3059688295db62037cdb Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 28 Nov 2019 21:36:35 +0000 Subject: Update for pandoc-types >=1.20 Signed-off-by: Sean Whitton --- debian/changelog | 1 + pandoc-citeproc-preamble.cabal | 3 ++- src/pandoc-citeproc-preamble.hs | 18 +++++++++++------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9673959..3916350 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,7 @@ pandoc-citeproc-preamble (1.2.5-1) UNRELEASED; urgency=medium From that release, pandoc-citeproc can add a 'hanging-indent' class to the refs Div, which broke pandoc-citeproc-preamble's selecting the refs Div. + * Update for pandoc-types >=1.20. * Add a simple integration test. * README.md: Don't specify a --resolver argument in the sample `stack install` command. diff --git a/pandoc-citeproc-preamble.cabal b/pandoc-citeproc-preamble.cabal index fdc91ca..4438ca4 100644 --- a/pandoc-citeproc-preamble.cabal +++ b/pandoc-citeproc-preamble.cabal @@ -15,10 +15,11 @@ executable pandoc-citeproc-preamble hs-source-dirs: src main-is: pandoc-citeproc-preamble.hs build-depends: base >= 4 && < 5 - , pandoc-types + , pandoc-types >= 1.20 , process , directory , filepath + , text-conversions default-language: Haskell2010 source-repository head diff --git a/src/pandoc-citeproc-preamble.hs b/src/pandoc-citeproc-preamble.hs index b446579..4716e4a 100644 --- a/src/pandoc-citeproc-preamble.hs +++ b/src/pandoc-citeproc-preamble.hs @@ -21,11 +21,13 @@ . -} +{-# LANGUAGE OverloadedStrings #-} -import Data.List (isPrefixOf) -import System.Directory (doesFileExist) -import System.FilePath ((<.>), ()) -import System.Process (readProcess) +import Data.List (isPrefixOf) +import Data.Text.Conversions (convertText) +import System.Directory (doesFileExist) +import System.FilePath ((<.>), ()) +import System.Process (readProcess) import Text.Pandoc.JSON insertPreamble :: Block -> [Block] -> [Block] @@ -45,7 +47,8 @@ doPreamble maybeFormat input@(Pandoc meta blocks) = >>= maybe (return input) (\file -> do ls <- readFile file - return $ Pandoc meta (insertPreamble (lsBlock ls) blocks)) + return $ + Pandoc meta (insertPreamble (lsBlock $ convertText ls) blocks)) where lsBlock ls = RawBlock format ls format = maybe (Format "latex") id maybeFormat @@ -57,7 +60,8 @@ findPreambleFile (Format format) meta = Nothing -> tryDatadir where tryDatadir = do - defaultPreamble <- ( "citeproc-preamble" "default" <.> format) + defaultPreamble <- ( "citeproc-preamble" "default" <.> + convertText format) <$> getPandocDatadir doesFileExist defaultPreamble >>= \exists -> return $ if exists then Just defaultPreamble else Nothing @@ -70,7 +74,7 @@ getPandocDatadir = prefix = "Default user data directory: " toPath :: MetaValue -> Maybe String -toPath (MetaString s) = Just s +toPath (MetaString s) = Just $ convertText s toPath _ = Nothing main :: IO () -- cgit v1.2.3