summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnMacFarlane <>2018-01-02 19:47:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-01-02 19:47:00 (GMT)
commitdc3aeaf5fd1bd2688ce64c3b0745edb472bf5f93 (patch)
treead03cd04696242f8771757432fd019cbf779c2c6
parentb87a915802fa8f5e3db26315559b0e10babfa483 (diff)
version 0.12.2.30.12.2.3
-rw-r--r--changelog9
-rw-r--r--pandoc-citeproc.cabal2
-rw-r--r--src/Text/CSL/Eval/Date.hs6
-rw-r--r--src/Text/CSL/Reference.hs9
-rw-r--r--tests/issue312.expected.native9
-rw-r--r--tests/issue312.in.native2
6 files changed, 26 insertions, 11 deletions
diff --git a/changelog b/changelog
index 639c2c6..36b67dd 100644
--- a/changelog
+++ b/changelog
@@ -1,4 +1,11 @@
-pandoc-citeproc (0.12.2.1)
+pandoc-citeproc (0.12.2.3)
+
+ * Fix month range problems (#312). Months in a range were being
+ concatenated with no separator with some styles (e.g. apa.csl).
+
+ * Use pseudo-months in CSL JSON output (#103).
+
+pandoc-citeproc (0.12.2.2)
* Allow pandoc 2.1.
diff --git a/pandoc-citeproc.cabal b/pandoc-citeproc.cabal
index 2cd20d2..76aca67 100644
--- a/pandoc-citeproc.cabal
+++ b/pandoc-citeproc.cabal
@@ -1,5 +1,5 @@
name: pandoc-citeproc
-version: 0.12.2.2
+version: 0.12.2.3
cabal-version: >= 1.12
synopsis: Supports using pandoc with citeproc
diff --git a/src/Text/CSL/Eval/Date.hs b/src/Text/CSL/Eval/Date.hs
index f8abc58..3782001 100644
--- a/src/Text/CSL/Eval/Date.hs
+++ b/src/Text/CSL/Eval/Date.hs
@@ -90,12 +90,8 @@ formatDate em k tm dp date
map (formatDatePart False a) x ++
map (formatDatePart False a) (init' y) ++
map (formatDatePart True a) (last' y) ++
- map (formatDatePart False b) (rmPrefix y) ++
+ map (formatDatePart False b) y ++
map (formatDatePart False b) z
- -- the point of rmPrefix is to remove the blank space that otherwise
- -- gets added after the delimiter in a range: 24- 26.
- rmPrefix (dp':rest) = dp'{ dpFormatting = (dpFormatting dp') { prefix = "" } } : rest
- rmPrefix [] = []
diff a b = filter (flip elem (diffDate a b) . dpName)
diffDate (RefDate ya ma sa da _ _)
(RefDate yb mb sb db _ _) = case () of
diff --git a/src/Text/CSL/Reference.hs b/src/Text/CSL/Reference.hs
index a534567..b1d256f 100644
--- a/src/Text/CSL/Reference.hs
+++ b/src/Text/CSL/Reference.hs
@@ -47,7 +47,7 @@ module Text.CSL.Reference ( Literal(..)
)
where
-import Control.Monad ( guard )
+import Control.Monad ( guard, mplus )
import Data.List ( elemIndex, intercalate )
import Data.List.Split ( splitWhen )
import Data.Maybe ( fromMaybe, isJust, isNothing )
@@ -216,7 +216,9 @@ handleLiteral d = [d]
toDatePart :: RefDate -> [Int]
toDatePart refdate =
case (safeRead (unLiteral $ year refdate),
- safeRead (unLiteral $ month refdate),
+ safeRead (unLiteral $ month refdate)
+ `mplus`
+ ((+ 12) <$> safeRead (unLiteral $ season refdate)),
safeRead (unLiteral $ day refdate)) of
(Just (y :: Int), Just (m :: Int), Just (d :: Int))
-> [y, m, d]
@@ -231,8 +233,7 @@ instance OVERLAPS
case filter (not . null) (map toDatePart xs) of
[] -> ["literal" .= intercalate "; " (map (unLiteral . other) xs)]
dps -> (["date-parts" .= dps ] ++
- ["circa" .= (1 :: Int) | or (map circa xs)] ++
- ["season" .= s | s <- map season xs, s /= mempty])
+ ["circa" .= (1 :: Int) | or (map circa xs)])
setCirca :: Bool -> RefDate -> RefDate
setCirca circa' rd = rd{ circa = circa' }
diff --git a/tests/issue312.expected.native b/tests/issue312.expected.native
new file mode 100644
index 0000000..9bffcfd
--- /dev/null
+++ b/tests/issue312.expected.native
@@ -0,0 +1,9 @@
+Pandoc (Meta {unMeta = fromList [("csl",MetaInlines [Str "tests/apa.csl"]),("references",MetaList [MetaMap (fromList [("id",MetaInlines [Str "item1"]),("issued",MetaList [MetaMap (fromList [("month",MetaInlines [Str "1"]),("year",MetaInlines [Str "-12"])]),MetaMap (fromList [("month",MetaInlines [Str "12"]),("year",MetaInlines [Str "12"])])]),("title",MetaInlines [Str "Title"]),("type",MetaInlines [Str "webpage"])]),MetaMap (fromList [("id",MetaInlines [Str "item2"]),("issued",MetaList [MetaMap (fromList [("month",MetaInlines [Str "11"]),("year",MetaInlines [Str "2016"])]),MetaMap (fromList [("month",MetaInlines [Str "12"]),("year",MetaInlines [Str "2017"])])]),("title",MetaInlines [Str "Title"]),("type",MetaInlines [Str "webpage"])]),MetaMap (fromList [("id",MetaInlines [Str "item3"]),("issued",MetaList [MetaMap (fromList [("season",MetaInlines [Str "1"]),("year",MetaInlines [Str "2016"])]),MetaMap (fromList [("season",MetaInlines [Str "2"]),("year",MetaInlines [Str "2017"])])]),("title",MetaInlines [Str "Title"]),("type",MetaInlines [Str "webpage"])])])]})
+[Para [Cite [Citation {citationId = "item1", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 1}] [Str "(",Str "\8220Title,\8221",Space,Str "12BC\8211\&12ADa)"],Str ";",Space,Cite [Citation {citationId = "item2", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 2}] [Str "(",Str "\8220Title,\8221",Space,Str "2016\8211\&2017b)"],Str ";",Space,Cite [Citation {citationId = "item3", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 3}] [Str "(",Str "\8220Title,\8221",Space,Str "2016\8211\&2017c)"]]
+,Div ("refs",["references"],[])
+ [Div ("ref-item1",[],[])
+ [Para [Str "Title.",Space,Str "(12BC\8211\&12ADa,",Space,Str "January,",Space,Str "December)."]]
+ ,Div ("ref-item2",[],[])
+ [Para [Str "Title.",Space,Str "(2016\8211\&2017b,",Space,Str "November,",Space,Str "December)."]]
+ ,Div ("ref-item3",[],[])
+ [Para [Str "Title.",Space,Str "(2016\8211\&2017c,",Space,Str "Spring,",Space,Str "Summer)."]]]]
diff --git a/tests/issue312.in.native b/tests/issue312.in.native
new file mode 100644
index 0000000..9d5c28c
--- /dev/null
+++ b/tests/issue312.in.native
@@ -0,0 +1,2 @@
+Pandoc (Meta {unMeta = fromList [("csl",MetaInlines [Str "tests/apa.csl"]),("references",MetaList [MetaMap (fromList [("id",MetaInlines [Str "item1"]),("issued",MetaList [MetaMap (fromList [("month",MetaInlines [Str "1"]),("year",MetaInlines [Str "-12"])]),MetaMap (fromList [("month",MetaInlines [Str "12"]),("year",MetaInlines [Str "12"])])]),("title",MetaInlines [Str "Title"]),("type",MetaInlines [Str "webpage"])]),MetaMap (fromList [("id",MetaInlines [Str "item2"]),("issued",MetaList [MetaMap (fromList [("month",MetaInlines [Str "11"]),("year",MetaInlines [Str "2016"])]),MetaMap (fromList [("month",MetaInlines [Str "12"]),("year",MetaInlines [Str "2017"])])]),("title",MetaInlines [Str "Title"]),("type",MetaInlines [Str "webpage"])]),MetaMap (fromList [("id",MetaInlines [Str "item3"]),("issued",MetaList [MetaMap (fromList [("season",MetaInlines [Str "1"]),("year",MetaInlines [Str "2016"])]),MetaMap (fromList [("season",MetaInlines [Str "2"]),("year",MetaInlines [Str "2017"])])]),("title",MetaInlines [Str "Title"]),("type",MetaInlines [Str "webpage"])])])]})
+[Para [Cite [Citation {citationId = "item1", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [Str "@item1"],Str ";",Space,Cite [Citation {citationId = "item2", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [Str "@item2"],Str ";",Space,Cite [Citation {citationId = "item3", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [Str "@item3"]]]