aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Citeproc.hs15
-rw-r--r--test/command/11046.md19
2 files changed, 29 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Citeproc.hs b/src/Text/Pandoc/Citeproc.hs
index 5ab245e16..199eb9d48 100644
--- a/src/Text/Pandoc/Citeproc.hs
+++ b/src/Text/Pandoc/Citeproc.hs
@@ -410,14 +410,14 @@ mvPunct moveNotes locale (x : xs)
mvPunct moveNotes locale (q : s : x@(Cite _ [il]) : ys)
| isSpacy s
, isNote il
- = let spunct = T.takeWhile isPunctuation $ stringify ys
+ = let spunct = T.takeWhile isPunct $ stringify ys
in if moveNotes
then if T.null spunct
then q : x : mvPunct moveNotes locale ys
else movePunctInsideQuotes locale
[q , Str spunct , x] ++ mvPunct moveNotes locale
(B.toList
- (dropTextWhile isPunctuation (B.fromList ys)))
+ (dropTextWhile isPunct (B.fromList ys)))
else q : x : mvPunct moveNotes locale ys
-- 'x[^1],' -> 'x,[^1]'
mvPunct moveNotes locale (Cite cs ils@(_:_) : ys)
@@ -425,13 +425,13 @@ mvPunct moveNotes locale (Cite cs ils@(_:_) : ys)
, startWithPunct ys
, moveNotes
= let s = stringify ys
- spunct = T.takeWhile isPunctuation s
+ spunct = T.takeWhile isPunct s
in Cite cs (movePunctInsideQuotes locale $
init ils
++ [Str spunct | not (endWithPunct False (init ils))]
++ [last ils]) :
mvPunct moveNotes locale
- (B.toList (dropTextWhile isPunctuation (B.fromList ys)))
+ (B.toList (dropTextWhile isPunct (B.fromList ys)))
mvPunct moveNotes locale (s : x@(Cite _ [il]) : ys)
| isSpacy s
, isNote il
@@ -444,13 +444,18 @@ mvPunct moveNotes locale (Cite cs ils : Str "." : ys)
mvPunct moveNotes locale (x:xs) = x : mvPunct moveNotes locale xs
mvPunct _ _ [] = []
+-- We don't treat an em-dash or en-dash as punctuation here, because we don't
+-- want notes and quotes to move around them.
+isPunct :: Char -> Bool
+isPunct c = isPunctuation c && c /= '\x2014' && c /= '\x2013'
+
endWithPunct :: Bool -> [Inline] -> Bool
endWithPunct _ [] = False
endWithPunct onlyFinal xs@(_:_) =
case reverse (T.unpack $ stringify xs) of
[] -> True
-- covers .), .", etc.:
- (d:c:_) | isPunctuation d
+ (d:c:_) | isPunct d
&& not onlyFinal
&& isEndPunct c -> True
(c:_) | isEndPunct c -> True
diff --git a/test/command/11046.md b/test/command/11046.md
new file mode 100644
index 000000000..ee5ffcd3b
--- /dev/null
+++ b/test/command/11046.md
@@ -0,0 +1,19 @@
+```
+% pandoc --citeproc -t plain+smart --csl command/chicago-note-bibliography.csl
+---
+references:
+- id: doe
+ title: Title
+ type: book
+ date: 2006
+ author: John Doe
+...
+
+blah blah [@doe]---blah blah.
+^D
+blah blah[1]---blah blah.
+
+John Doe. Title, n.d.
+
+[1] John Doe, Title.
+```