diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-10-21 22:23:21 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-10-21 22:23:21 -0700 |
commit | f9c6167ad123032b67f300b2478466063e0ac6f6 (patch) | |
tree | b053b3a9d2d8ea85bff6a02e3d12a51192946db5 /src/Text | |
parent | 76315d99caabf39c9d6e743da844327e1b3a018a (diff) | |
download | pandoc-f9c6167ad123032b67f300b2478466063e0ac6f6.tar.gz |
citeproc - improved removal of final period...
...in citations inside notes in note-based styles.
These citations are put in parentheses, but the final
period must be removed.
See jgm/citeproc#20
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Citeproc.hs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Citeproc.hs b/src/Text/Pandoc/Citeproc.hs index c00c8ca09..ec7954d47 100644 --- a/src/Text/Pandoc/Citeproc.hs +++ b/src/Text/Pandoc/Citeproc.hs @@ -524,11 +524,14 @@ deNote (Note bs) = Note $ walk go bs go x = x deNote x = x --- Note: we can't use dropTextWhileEnd because this would --- remove the final period on abbreviations like Ibid. --- But removing a final Str "." is safe. +-- Note: we can't use dropTextWhileEnd indiscriminately, +-- because this would remove the final period on abbreviations like Ibid. +-- But it turns out that when the note citation ends with Ibid. +-- (or Ed. etc.), the last inline will be Str "" as a result of +-- the punctuation-fixing mechanism that removes the double '.'. removeFinalPeriod :: [Inline] -> [Inline] removeFinalPeriod ils = case lastMay ils of - Just (Str ".") -> initSafe ils - _ -> ils + Just (Str t) + | T.takeEnd 1 t == "." -> initSafe ils ++ [Str (T.dropEnd 1 t)] + _ -> ils |