summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnMacFarlane <>2019-04-19 04:27:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2019-04-19 04:27:00 (GMT)
commita35b843c10b0eade1433dc07c82d394ef21d6548 (patch)
tree3cf08f811f9634c01405333a06d17c4ba8842a69
parentc53df0fb671bee5e8ba81cab9489a23b9743d92d (diff)
version 0.16.20.16.2
-rw-r--r--changelog15
-rw-r--r--man/man1/pandoc-citeproc.17
-rw-r--r--pandoc-citeproc.cabal2
-rw-r--r--src/Text/CSL/Eval/Common.hs3
-rw-r--r--src/Text/CSL/Eval/Names.hs7
-rw-r--r--src/Text/CSL/Reference.hs3
-rw-r--r--src/Text/CSL/Style.hs10
-rw-r--r--src/Text/CSL/Util.hs2
-rw-r--r--stack.yaml7
-rw-r--r--tests/issue392.expected.native4
-rw-r--r--tests/issue392.in.native2
-rw-r--r--tests/issue399.expected.native2
-rw-r--r--tests/issue399.in.native2
-rw-r--r--tests/style399.csl12
14 files changed, 59 insertions, 19 deletions
diff --git a/changelog b/changelog
index ba1cc0e..2ca4612 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,18 @@
+pandoc-citeproc (0.16.2)
+
+ * Normalize for sorting by padding numerical strings with 0s (#399).
+ This is a somewhat ugly fix to #399, and might be wrong
+ if there are strings that may be numerical and should not
+ be sorted in numerical order. But this is the best we can
+ do right now without major archictectural changes.
+ * Add Ord instance for CNum. [Minor API change.]
+ * Allow empty sort-separator.
+ Previously this was overridden with the default.
+ Text.CSL.Common: export getOptionValWithDefault [API change].
+ * Fix omitted phrase in --man documentation (#394, Daniel Himmelstein).
+ * Amend fix to #392 (#393). Initials were being dropped when there were
+ more than two unspaced initials.
+
pandoc-citeproc (0.16.1.3)
* Correctly handle initials even when
diff --git a/man/man1/pandoc-citeproc.1 b/man/man1/pandoc-citeproc.1
index 8497667..208218a 100644
--- a/man/man1/pandoc-citeproc.1
+++ b/man/man1/pandoc-citeproc.1
@@ -1,7 +1,7 @@
.\"t
-.\" Automatically generated by Pandoc 2.7
+.\" Automatically generated by Pandoc 2.7.1
.\"
-.TH "pandoc-citeproc" "1" "2019-03-12" "pandoc-citeproc 0.16.1.3" ""
+.TH "pandoc-citeproc" "1" "2019-03-26" "pandoc-citeproc 0.16.1.3" ""
.hy
.SH NAME
.PP
@@ -296,7 +296,8 @@ Print usage information.
Print the man page in groff man format.
To get a plain text version,
\f[C]pandoc-citeproc --man | groff -mman -Tutf8\f[R].
-To \f[C]pandoc-citeproc --man | groff -mman -Thtml\f[R].
+To get an HTML version,
+\f[C]pandoc-citeproc --man | groff -mman -Thtml\f[R].
.TP
.B \f[C]--license\f[R]
Print the license.
diff --git a/pandoc-citeproc.cabal b/pandoc-citeproc.cabal
index 301a077..3642e4e 100644
--- a/pandoc-citeproc.cabal
+++ b/pandoc-citeproc.cabal
@@ -1,5 +1,5 @@
name: pandoc-citeproc
-version: 0.16.1.3
+version: 0.16.2
cabal-version: 1.12
synopsis: Supports using pandoc with citeproc
diff --git a/src/Text/CSL/Eval/Common.hs b/src/Text/CSL/Eval/Common.hs
index f13462e..78fbfbe 100644
--- a/src/Text/CSL/Eval/Common.hs
+++ b/src/Text/CSL/Eval/Common.hs
@@ -134,6 +134,9 @@ getStringValue val =
getOptionVal :: String -> [Option] -> String
getOptionVal s = fromMaybe [] . lookup s
+getOptionValWithDefault :: String -> String -> [Option] -> String
+getOptionValWithDefault s defvalue = fromMaybe defvalue . lookup s
+
isOptionSet :: String -> [Option] -> Bool
isOptionSet s = maybe False (not . null) . lookup s
diff --git a/src/Text/CSL/Eval/Names.hs b/src/Text/CSL/Eval/Names.hs
index 296f432..3d8b260 100644
--- a/src/Text/CSL/Eval/Names.hs
+++ b/src/Text/CSL/Eval/Names.hs
@@ -279,12 +279,9 @@ formatName m b f fm ops np n
sortSep g s = when_ g $ separator ++ addAffixes (g <+> s) "given" mempty
separator = if isByzantineFamily
- then
- if null (getOptionVal "sort-separator" ops)
- then [OPan [Str ",", Space]]
- else [OPan $ B.toList $ B.text $ getOptionVal "sort-separator" ops]
+ then [OPan (B.toList (B.text
+ (getOptionValWithDefault "sort-separator" ", " ops)))]
else []
-
suff = if commaSuffix n && nameSuffix n /= mempty
then suffCom
else suffNoCom
diff --git a/src/Text/CSL/Reference.hs b/src/Text/CSL/Reference.hs
index 40dec4b..6debb12 100644
--- a/src/Text/CSL/Reference.hs
+++ b/src/Text/CSL/Reference.hs
@@ -382,7 +382,8 @@ handleSpecialCases "personal-communication" = "personal_communication"
handleSpecialCases "legal-case" = "legal_case"
handleSpecialCases x = x
-newtype CNum = CNum { unCNum :: Int } deriving ( Show, Read, Eq, Num, Typeable, Data, Generic )
+newtype CNum = CNum { unCNum :: Int }
+ deriving ( Show, Read, Eq, Ord, Num, Typeable, Data, Generic )
instance FromJSON CNum where
parseJSON x = CNum `fmap` parseInt x
diff --git a/src/Text/CSL/Style.hs b/src/Text/CSL/Style.hs
index b7fec18..6f60ffb 100644
--- a/src/Text/CSL/Style.hs
+++ b/src/Text/CSL/Style.hs
@@ -100,7 +100,7 @@ import Control.Monad (mplus)
import Data.Aeson hiding (Number)
import qualified Data.Aeson as Aeson
import Data.Aeson.Types (Pair)
-import Data.Char (isLetter, isPunctuation, isUpper, toLower)
+import Data.Char (isLetter, isPunctuation, isUpper, toLower, isDigit)
import qualified Data.Char as Char
import Data.Generics (Data, Typeable)
import Data.List (intercalate, intersperse, isInfixOf,
@@ -491,7 +491,13 @@ compare' x y
(_ ,'-':_) -> GT
_ -> comp (normalize x) (normalize y)
where
- normalize = map (\c -> if c == ',' || c == '.' then ' ' else c) .
+ -- we zero pad numbers so they're sorted numerically, see #399
+ zeropad [] = []
+ zeropad xs = if all isDigit xs
+ then replicate (10 - length xs) '0' ++ xs
+ else xs
+ normalize = zeropad .
+ map (\c -> if c == ',' || c == '.' then ' ' else c) .
filter (\c -> c == ',' ||
not (isPunctuation c || Char.isSpace c
-- ayn/hamza in transliterated arabic:
diff --git a/src/Text/CSL/Util.hs b/src/Text/CSL/Util.hs
index b8938d7..97ff10a 100644
--- a/src/Text/CSL/Util.hs
+++ b/src/Text/CSL/Util.hs
@@ -544,5 +544,5 @@ addSpaceAfterPeriod = go . splitStrWhen (=='.')
| isLetter d
, isLetter c
, isUpper c
- , isUpper d = Str [c]:Str ".":Space:Str [d]:go xs
+ , isUpper d = Str [c]:Str ".":Space:go (Str [d]:xs)
go (x:xs) = x:go xs
diff --git a/stack.yaml b/stack.yaml
index 5a386f2..d2211f4 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -9,11 +9,12 @@ flags:
packages:
- '.'
extra-deps:
-- pandoc-2.7
-- texmath-0.11.2.1
+- pandoc-2.7.2
+- texmath-0.11.2.2
- skylighting-core-0.7.7
- skylighting-0.7.7
- ipynb-0.1
+- cmark-gfm-0.2.0
ghc-options:
"$locals": -fhide-source-paths
-resolver: lts-13.5
+resolver: lts-13.9
diff --git a/tests/issue392.expected.native b/tests/issue392.expected.native
index c3b6279..c32bc6e 100644
--- a/tests/issue392.expected.native
+++ b/tests/issue392.expected.native
@@ -1,7 +1,7 @@
-Pandoc (Meta {unMeta = fromList [("csl",MetaInlines [Str "tests/vancouver.csl"]),("references",MetaList [MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "James"]),("given",MetaInlines [Str "M.R."])])]),("id",MetaInlines [Str "james"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "MacFarlane"]),("given",MetaInlines [Str "J.",Space,Str "G."])])]),("id",MetaInlines [Str "macfarlane"])])])]})
+Pandoc (Meta {unMeta = fromList [("csl",MetaInlines [Str "tests/vancouver.csl"]),("references",MetaList [MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "James"]),("given",MetaInlines [Str "M.R.C.E.L."])])]),("id",MetaInlines [Str "james"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "MacFarlane"]),("given",MetaInlines [Str "J.",Space,Str "G."])])]),("id",MetaInlines [Str "macfarlane"])])])]})
[Para [Cite [Citation {citationId = "james", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 1}] [Str "(1)"],Str ";",Space,Cite [Citation {citationId = "macfarlane", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 2}] [Str "(2)"]]
,Div ("refs",["references"],[])
[Div ("ref-james",[],[])
- [Para [Str "1.",Space,Str "James",Space,Str "MR.",Space]]
+ [Para [Str "1.",Space,Str "James",Space,Str "MRCEL.",Space]]
,Div ("ref-macfarlane",[],[])
[Para [Str "2.",Space,Str "MacFarlane",Space,Str "JG.",Space]]]]
diff --git a/tests/issue392.in.native b/tests/issue392.in.native
index d70fee4..38588d0 100644
--- a/tests/issue392.in.native
+++ b/tests/issue392.in.native
@@ -1,2 +1,2 @@
-Pandoc (Meta {unMeta = fromList [("csl",MetaInlines [Str "tests/vancouver.csl"]),("references",MetaList [MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "James"]),("given",MetaInlines [Str "M.R."])])]),("id",MetaInlines [Str "james"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "MacFarlane"]),("given",MetaInlines [Str "J.",Space,Str "G."])])]),("id",MetaInlines [Str "macfarlane"])])])]})
+Pandoc (Meta {unMeta = fromList [("csl",MetaInlines [Str "tests/vancouver.csl"]),("references",MetaList [MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "James"]),("given",MetaInlines [Str "M.R.C.E.L."])])]),("id",MetaInlines [Str "james"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "MacFarlane"]),("given",MetaInlines [Str "J.",Space,Str "G."])])]),("id",MetaInlines [Str "macfarlane"])])])]})
[Para [Cite [Citation {citationId = "james", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [Str "@james"],Str ";",Space,Cite [Citation {citationId = "macfarlane", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [Str "@macfarlane"]]]
diff --git a/tests/issue399.expected.native b/tests/issue399.expected.native
new file mode 100644
index 0000000..c4c1f3f
--- /dev/null
+++ b/tests/issue399.expected.native
@@ -0,0 +1,2 @@
+Pandoc (Meta {unMeta = fromList [("csl",MetaInlines [Str "tests/style399.csl"]),("references",MetaList [MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "One"])])]),("id",MetaInlines [Str "one"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Two"])])]),("id",MetaInlines [Str "two"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Three"])])]),("id",MetaInlines [Str "three"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Four"])])]),("id",MetaInlines [Str "four"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Five"])])]),("id",MetaInlines [Str "five"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Six"])])]),("id",MetaInlines [Str "six"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Seven"])])]),("id",MetaInlines [Str "seven"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Eight"])])]),("id",MetaInlines [Str "eight"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Nine"])])]),("id",MetaInlines [Str "nine"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Ten"])])]),("id",MetaInlines [Str "ten"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Eleven"])])]),("id",MetaInlines [Str "eleven"])])])]})
+[Para [Str "Inline",Space,Str "citation",Space,Cite [Citation {citationId = "one", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 1},Citation {citationId = "two", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 2},Citation {citationId = "three", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 3},Citation {citationId = "four", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 4},Citation {citationId = "five", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 5},Citation {citationId = "six", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 6},Citation {citationId = "seven", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 7},Citation {citationId = "eight", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 8},Citation {citationId = "nine", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 9},Citation {citationId = "ten", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 10},Citation {citationId = "eleven", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 11}] [Str "[1,2,3,4,5,6,7,8,9,10,11]"],Str "."]]
diff --git a/tests/issue399.in.native b/tests/issue399.in.native
new file mode 100644
index 0000000..6e87770
--- /dev/null
+++ b/tests/issue399.in.native
@@ -0,0 +1,2 @@
+Pandoc (Meta {unMeta = fromList [("csl",MetaInlines [Str "tests/style399.csl"]),("references",MetaList [MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "One"])])]),("id",MetaInlines [Str "one"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Two"])])]),("id",MetaInlines [Str "two"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Three"])])]),("id",MetaInlines [Str "three"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Four"])])]),("id",MetaInlines [Str "four"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Five"])])]),("id",MetaInlines [Str "five"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Six"])])]),("id",MetaInlines [Str "six"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Seven"])])]),("id",MetaInlines [Str "seven"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Eight"])])]),("id",MetaInlines [Str "eight"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Nine"])])]),("id",MetaInlines [Str "nine"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Ten"])])]),("id",MetaInlines [Str "ten"])]),MetaMap (fromList [("author",MetaList [MetaMap (fromList [("family",MetaInlines [Str "Eleven"])])]),("id",MetaInlines [Str "eleven"])])])]})
+[Para [Str "Inline",Space,Str "citation",Space,Cite [Citation {citationId = "one", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0},Citation {citationId = "two", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0},Citation {citationId = "three", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0},Citation {citationId = "four", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0},Citation {citationId = "five", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0},Citation {citationId = "six", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0},Citation {citationId = "seven", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0},Citation {citationId = "eight", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0},Citation {citationId = "nine", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0},Citation {citationId = "ten", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0},Citation {citationId = "eleven", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[@one;",Space,Str "@two;",Space,Str "@three;",Space,Str "@four;",Space,Str "@five;",Space,Str "@six;",Space,Str "@seven;",Space,Str "@eight;",Space,Str "@nine;",Space,Str "@ten;",Space,Str "@eleven]"],Str "."]]
diff --git a/tests/style399.csl b/tests/style399.csl
new file mode 100644
index 0000000..41a81f4
--- /dev/null
+++ b/tests/style399.csl
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never" default-locale="en-US">
+ <citation>
+ <sort>
+ <key variable="citation-number"/>
+ </sort>
+ <layout prefix="[" suffix="]" delimiter=",">
+ <text variable="citation-number"/>
+ </layout>
+ </citation>
+</style>
+