pandoc-crossref 0.2.4.2 → 0.2.5.0
raw patch · 5 files changed
+42/−11 lines, 5 filesdep ~directorydep ~filepathdep ~sybPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: directory, filepath, syb
API changes (from Hackage documentation)
Files
- README.md +9/−0
- lib/Text/Pandoc/CrossRef.hs +1/−1
- lib/Text/Pandoc/CrossRef/Util/Settings.hs +20/−7
- pandoc-crossref.cabal +7/−3
- test/test-integrative.hs +5/−0
README.md view
@@ -539,6 +539,15 @@ `pandoc -F pandoc-crossref.hs -M "crossrefYaml=$HOME/misc/pandoc-crossref-es.yaml"` +You can also use global configuration files, which are expected in `$HOME/.pandoc-crossref/config.yaml` and `$HOME/.pandoc-crossref/config-$FORMAT.yaml`, where `$FORMAT` is output format, f.ex. `latex` or `epub`. On Windows, `$HOME` in general resolves to user's root directory, e.g. `C:\Users\username\`.++Priorities are as follows (from highest to lowest):++- document metadata+- `crossrefYaml`/`$CWD/pandoc-crossref.yaml`+- `$HOME/.pandoc-crossref/config-$FORMAT.yaml`+- `$HOME/.pandoc-crossref/config.yaml`+ # License This software is licensed under GNU GPL 2. See [LICENSE.md](https://github.com/lierdakil/pandoc-crossref/blob/master/LICENSE.md) for details.
lib/Text/Pandoc/CrossRef.hs view
@@ -133,7 +133,7 @@ file specified by crossrefYaml metadata field. -} runCrossRefIO :: forall a b. Meta -> Maybe Format -> (a -> CrossRefM b) -> a -> IO b runCrossRefIO meta fmt action arg = do- settings <- getSettings meta+ settings <- getSettings fmt meta let env = CrossRefEnv { creSettings = settings
lib/Text/Pandoc/CrossRef/Util/Settings.hs view
@@ -8,14 +8,27 @@ import Text.Pandoc.CrossRef.Util.Settings.Gen import Text.Pandoc.CrossRef.Util.Meta import Text.Pandoc.CrossRef.Util.PandocOrphans()+import System.Directory+import System.FilePath -getSettings :: Meta -> IO Meta-getSettings meta = do- let handler :: IOException -> IO String- handler _ = return []- yaml <- handle handler $ readFile (getMetaString "crossrefYaml" (meta <> defaultMeta))- let Pandoc dtve _ = readMarkdown def ("---\n" ++ yaml ++ "\n---")- return $ meta <> dtve <> defaultMeta+getSettings :: Maybe Format -> Meta -> IO Meta+getSettings fmt meta = do+ dirConfig <- readConfig (getMetaString "crossrefYaml" (meta <> defaultMeta))+ home <- getHomeDirectory+ globalConfig <- readConfig (home </> ".pandoc-crossref" </> "config.yaml")+ formatConfig <- maybe (return nullMeta) (readFmtConfig home) fmt+ return $ meta <> dirConfig <> formatConfig <> globalConfig <> defaultMeta+ where+ readConfig path =+ handle handler $ do+ yaml <- readFile path+ let Pandoc meta' _ = readMarkdown def ("---\n" ++ yaml ++ "\n---")+ return meta'+ readFmtConfig home fmt' = readConfig (home </> ".pandoc-crossref" </> "config-" ++ fmtStr fmt' ++ ".yaml")+ handler :: IOException -> IO Meta+ handler _ = return nullMeta+ fmtStr (Format fmtstr) = fmtstr+ defaultMeta :: Meta defaultMeta =
pandoc-crossref.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: pandoc-crossref-version: 0.2.4.2+version: 0.2.5.0 synopsis: Pandoc filter for cross-references description: pandoc-crossref is a pandoc filter for numbering figures, equations, tables and cross-references to them. license: GPL-2@@ -40,7 +40,7 @@ source-repository this type: git location: https://github.com/lierdakil/pandoc-crossref- tag: v0.2.4.2+ tag: v0.2.5.0 library exposed-modules: Text.Pandoc.CrossRef@@ -62,7 +62,7 @@ Text.Pandoc.CrossRef.Util.Gap Text.Pandoc.CrossRef.Util.PandocOrphans build-depends: base >=4.8 && <5- , pandoc >= 1.17.1 && <1.19+ , pandoc >= 1.17.1 && <1.20 , pandoc-types >= 1.16 && < 1.18 , mtl >= 1.1 && <2.3 , containers >= 0.1 && <0.6@@ -74,6 +74,8 @@ , roman-numerals == 0.5.* , syb >= 0.4 && < 0.7 , utility-ht >= 0.0.11 && < 0.1.0+ , directory >= 1 && < 1.4+ , filepath >= 1.1 && < 1.5 hs-source-dirs: lib if impl(ghc >= 8.0.1) hs-source-dirs: ghc-8@@ -114,6 +116,8 @@ , template-haskell , utility-ht , data-accessor+ , directory+ , filepath , data-accessor-transformers other-modules: Native
test/test-integrative.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} import Test.Hspec import Text.Pandoc import Text.Pandoc.CrossRef@@ -16,7 +17,11 @@ | otherwise = describe dir $ do input <- runIO $ readFile ("test" </> "m2m" </> dir </> "input.md")+#if MIN_VERSION_pandoc(1,19,0)+ expect_md <- runIO $ readFile ("test" </> "m2m" </> dir </> "expect-1.19.md")+#else expect_md <- runIO $ readFile ("test" </> "m2m" </> dir </> "expect.md")+#endif expect_tex <- runIO $ readFile ("test" </> "m2m" </> dir </> "expect.tex") p@(Pandoc meta _) <- either (fail . show) return $ readMarkdown def input let actual_md = writeMarkdown def $ runCrossRef meta (Just $ Format "markdown") defaultCrossRefAction p