aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2019-11-28 21:36:35 +0000
committerSean Whitton <spwhitton@spwhitton.name>2019-11-28 21:36:35 +0000
commitb08997cd90c9eef58e5e3059688295db62037cdb (patch)
tree1cfcd12645b3bdc4ab6b520755f1c961382185ff
parent45688c8253fe61907f2743c267d65950cf74c4b5 (diff)
downloadpandoc-citeproc-preamble-b08997cd90c9eef58e5e3059688295db62037cdb.tar.gz
Update for pandoc-types >=1.20
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--debian/changelog1
-rw-r--r--pandoc-citeproc-preamble.cabal3
-rw-r--r--src/pandoc-citeproc-preamble.hs18
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 @@
<http://www.gnu.org/licenses/>.
-}
+{-# 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 ()