packages feed

pandoc-citeproc 0.1.1.1 → 0.1.1.2

raw patch · 3 files changed

+29/−20 lines, 3 filesdep +pandocdep ~bytestringdep ~pandoc-types

Dependencies added: pandoc

Dependency ranges changed: bytestring, pandoc-types

Files

pandoc-citeproc.cabal view
@@ -1,5 +1,5 @@ name:               pandoc-citeproc-version:            0.1.1.1+version:            0.1.1.2 cabal-version:      >= 1.12 synopsis:           Supports using pandoc with citeproc @@ -146,7 +146,7 @@     ghc-options:      -funbox-strict-fields -Wall     ghc-prof-options: -prof -auto-all     build-depends:    containers, directory, mtl, json, utf8-string,-                      bytestring, filepath, pandoc-types >= 1.12, tagsoup,+                      bytestring, filepath, pandoc-types >= 1.12.2.3, tagsoup,                       aeson, text, vector, texmath >= 0.6.4      if flag(bibutils)@@ -192,7 +192,7 @@     hs-source-dirs:   .     ghc-options:      -funbox-strict-fields -Wall     ghc-prof-options: -prof -auto-all-    build-depends:    base >= 4, pandoc-citeproc, pandoc-types >= 1.12, aeson+    build-depends:    base >= 4, pandoc-citeproc, pandoc-types >= 1.12.2.3, aeson     default-language: Haskell98  executable biblio2yaml@@ -208,6 +208,8 @@   Type:           exitcode-stdio-1.0   Main-Is:        test-pandoc-citeproc.hs   Hs-Source-Dirs: tests-  build-depends:  base >= 4, utf8-string, aeson-pretty, aeson, pandoc-types,+  build-depends:  base >= 4, aeson-pretty, aeson,+                  pandoc-types >= 1.12.2.3, pandoc >= 1.12,+                  bytestring >= 0.10 && < 0.11,                   pandoc-citeproc, process, Diff >= 0.3   default-language: Haskell98
src/Text/CSL/Pandoc.hs view
@@ -62,9 +62,11 @@   csl <- maybe (getDefaultCSL >>= parseCSL')           (\f -> findFile [".", csldir] f >>= L.readFile >>= parseCSL') cslfile   let cslAbbrevFile = lookupMeta "citation-abbreviations" meta >>= toPath+  let isSpaceOrTab s = s == ' ' || s == '\t'   abbrevs <- maybe (return [])-             (\f -> findFile [".", csldir] f >>= readJsonAbbrevFile)-                cslAbbrevFile+             (\f -> findFile [".", csldir] f >>=+               readJsonAbbrevFile . dropWhile isSpaceOrTab)+             cslAbbrevFile   let csl' = csl{ styleAbbrevs = abbrevs }   return $ processCites csl' refs $ Pandoc meta blocks 
tests/test-pandoc-citeproc.hs view
@@ -6,10 +6,12 @@ import Data.Monoid (mempty) import Data.Algorithm.Diff import Text.Printf-import Data.ByteString.Lazy.UTF8 (fromString, toString) import Data.Aeson (decode) import Data.Aeson.Encode.Pretty import Text.Pandoc.Definition+import qualified Data.ByteString.Lazy.Char8 as BL+import qualified Text.Pandoc.UTF8 as UTF8+import Text.Pandoc.Process (pipeProcess)  main = do   testCase "chicago-author-date"@@ -23,22 +25,25 @@ testCase :: String -> IO () testCase csl = do   err $ "TEST: " ++ csl-  indata <- readFile $ "tests/" ++ csl ++ ".in.json"-  expected <- readFile $ "tests/" ++ csl ++ ".expected.json"-  (ec, result, errout) <- readProcessWithExitCode+  indata <- BL.readFile $ "tests/" ++ csl ++ ".in.json"+  expected <- BL.readFile $ "tests/" ++ csl ++ ".expected.json"+  (ec, result, errout) <- pipeProcess+                     (Just [("LANG","en_US.UTF-8"),("HOME",".")])                      "dist/build/pandoc-citeproc/pandoc-citeproc"                      [] indata   if ec == ExitSuccess      then do        let resultDoc :: Maybe Pandoc-           resultDoc = decode $ fromString result+           resultDoc = decode result        let expectedDoc :: Maybe Pandoc-           expectedDoc = decode $ fromString expected-       let result' = maybe [] (lines . toString-                     . encodePretty' Config{ confIndent = 2, confCompare = compare } )+           expectedDoc = decode expected+       let result' = maybe [] (BL.lines+                     . encodePretty' Config{ confIndent = 2+                                           , confCompare = compare } )                      resultDoc-       let expected' = maybe [] (lines . toString-                     . encodePretty' Config{ confIndent = 2, confCompare = compare } )+       let expected' = maybe [] (BL.lines+                     . encodePretty' Config{ confIndent = 2+                                           , confCompare = compare } )                      expectedDoc        if result' == expected'           then return ()@@ -48,15 +53,15 @@             exitWith $ ExitFailure 1      else do        err $ "Error status " ++ show ec-       err errout+       err $ UTF8.toStringLazy errout        exitWith ec -showDiff :: (Int,Int) -> [Diff String] -> String+showDiff :: (Int,Int) -> [Diff BL.ByteString] -> String showDiff _ []             = "" showDiff (l,r) (First ln : ds) =-  printf "+%4d " l ++ ln ++ "\n" ++ showDiff (l+1,r) ds+  printf "+%4d " l ++ (UTF8.toStringLazy ln) ++ "\n" ++ showDiff (l+1,r) ds showDiff (l,r) (Second ln : ds) =-  printf "-%4d " r ++ ln ++ "\n" ++ showDiff (l,r+1) ds+  printf "-%4d " r ++ (UTF8.toStringLazy ln) ++ "\n" ++ showDiff (l,r+1) ds showDiff (l,r) (Both _ _ : ds) =   showDiff (l+1,r+1) ds