summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnMacFarlane <>2018-02-01 19:57:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-02-01 19:57:00 (GMT)
commitacb796c57c1f9972f0efdc4a7c895f1dd3983de8 (patch)
tree4d5f401a643f8d23a02b0626366b9f5f777aa75b
parent7e6a4cdbbf521ecbe420c0d80937fa27f550cb90 (diff)
version 0.14.1.20.14.1.2
-rw-r--r--changelog7
-rw-r--r--pandoc-citeproc.cabal2
-rw-r--r--src/Text/CSL/Reference.hs22
3 files changed, 19 insertions, 12 deletions
diff --git a/changelog b/changelog
index 2d732c8..8c87646 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,10 @@
+pandoc-citeproc (0.14.1.2)
+
+ * Fix regression in JSON output for date-parts (#321).
+ Previous versions of represented dates as:
+ `"issued": {"date-parts": [[2006]]}`. pandoc-citeproc 0.14
+ did instead: `"issued": [{"date-parts": [2006]}]`.
+
pandoc-citeproc (0.14.1.1)
* Fix regression in movement of punctuation inside quotes before note.
diff --git a/pandoc-citeproc.cabal b/pandoc-citeproc.cabal
index fad614a..e6c4e30 100644
--- a/pandoc-citeproc.cabal
+++ b/pandoc-citeproc.cabal
@@ -1,5 +1,5 @@
name: pandoc-citeproc
-version: 0.14.1.1
+version: 0.14.1.2
cabal-version: >= 1.12
synopsis: Supports using pandoc with citeproc
diff --git a/src/Text/CSL/Reference.hs b/src/Text/CSL/Reference.hs
index 9bec268..2e5391a 100644
--- a/src/Text/CSL/Reference.hs
+++ b/src/Text/CSL/Reference.hs
@@ -56,7 +56,7 @@ module Text.CSL.Reference ( Literal(..)
where
import Control.Applicative ((<|>))
-import Control.Monad (guard, mplus)
+import Control.Monad (guard, mplus, msum)
import Data.Aeson hiding (Value)
import qualified Data.Aeson as Aeson
import Data.Aeson.Types (Parser)
@@ -258,20 +258,20 @@ instance OVERLAPS
instance OVERLAPS
ToJSON [RefDate] where
- toJSON [] = Array V.empty
- toJSON xs = toJSON $ map toJSONDate xs
-
-toJSONDate :: RefDate -> Aeson.Value
-toJSONDate rd = object' $
- [ "date-parts" .= dateparts | not (emptyDatePart dateparts) ] ++
- ["circa" .= (1 :: Int) | circa rd] ++
- (case season rd of
+ toJSON = toJSONDate
+
+toJSONDate :: [RefDate] -> Aeson.Value
+toJSONDate [] = Array V.empty
+toJSONDate ds = object' $
+ [ "date-parts" .= dateparts | not (null dateparts) ] ++
+ ["circa" .= (1 :: Int) | any circa ds] ++
+ (case msum (map season ds) of
Just (RawSeason s) -> ["season" .= s]
_ -> []) ++
- (case other rd of
+ (case mconcat (map other ds) of
Literal l | not (null l) -> ["literal" .= l]
_ -> [])
- where dateparts = toDatePart rd
+ where dateparts = filter (not . emptyDatePart) $ map toDatePart ds
emptyDatePart [] = True
emptyDatePart xs = all (== 0) xs