Skip to content

Commit c584331

Browse files
jgmchristopherkenny
authored andcommitted
Citeproc: fix moving punctuation before citation notes.
This previously worked with regular citations, but not author-in-text citations. Now it works with both.
1 parent e76ef5f commit c584331

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

src/Text/Pandoc/Citeproc.hs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -382,12 +382,12 @@ getBibliographyFormat fp mbmime = do
382382
_ -> Nothing
383383

384384
isNote :: Inline -> Bool
385-
isNote (Cite _ [Note _]) = True
386-
-- the following allows citation styles that are "in-text" but use superscript
387-
-- references to be treated as if they are "notes" for the purposes of moving
388-
-- the citations after trailing punctuation (see <https://github.com/jgm/pandoc-citeproc/issues/382>):
389-
isNote (Cite _ [Superscript _]) = True
390-
isNote _ = False
385+
isNote (Note _) = True
386+
-- the following allows citation styles that are "in-text" but use superscript
387+
-- references to be treated as if they are "notes" for the purposes of moving
388+
-- the citations after trailing punctuation (see <https://github.com/jgm/pandoc-citeproc/issues/382>):
389+
isNote (Superscript _) = True
390+
isNote _ = False
391391

392392
isSpacy :: Inline -> Bool
393393
isSpacy Space = True
@@ -405,9 +405,9 @@ mvPunct :: Bool -> Locale -> [Inline] -> [Inline]
405405
mvPunct moveNotes locale (x : xs)
406406
| isSpacy x = x : mvPunct moveNotes locale xs
407407
-- 'x [^1],' -> 'x,[^1]'
408-
mvPunct moveNotes locale (q : s : x : ys)
408+
mvPunct moveNotes locale (q : s : x@(Cite _ [il]) : ys)
409409
| isSpacy s
410-
, isNote x
410+
, isNote il
411411
= let spunct = T.takeWhile isPunctuation $ stringify ys
412412
in if moveNotes
413413
then if T.null spunct
@@ -418,9 +418,8 @@ mvPunct moveNotes locale (q : s : x : ys)
418418
(dropTextWhile isPunctuation (B.fromList ys)))
419419
else q : x : mvPunct moveNotes locale ys
420420
-- 'x[^1],' -> 'x,[^1]'
421-
mvPunct moveNotes locale (Cite cs ils : ys)
422-
| not (null ils)
423-
, isNote (last ils)
421+
mvPunct moveNotes locale (Cite cs ils@(_:_) : ys)
422+
| isNote (last ils)
424423
, startWithPunct ys
425424
, moveNotes
426425
= let s = stringify ys
@@ -431,8 +430,10 @@ mvPunct moveNotes locale (Cite cs ils : ys)
431430
++ [last ils]) :
432431
mvPunct moveNotes locale
433432
(B.toList (dropTextWhile isPunctuation (B.fromList ys)))
434-
mvPunct moveNotes locale (s : x : ys) | isSpacy s, isNote x =
435-
x : mvPunct moveNotes locale ys
433+
mvPunct moveNotes locale (s : x@(Cite _ [il]) : ys)
434+
| isSpacy s
435+
, isNote il
436+
= x : mvPunct moveNotes locale ys
436437
mvPunct moveNotes locale (s : x@(Cite _ (Superscript _ : _)) : ys)
437438
| isSpacy s = x : mvPunct moveNotes locale ys
438439
mvPunct moveNotes locale (Cite cs ils : Str "." : ys)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
```
2+
% pandoc --citeproc --csl command/chicago-fullnote-bibliography.csl -t plain
3+
---
4+
references:
5+
- id: foo
6+
type: book
7+
author: John Doe
8+
title: A Book
9+
...
10+
11+
See @foo [p. 21], as well.
12+
^D
13+
See John Doe,[1] as well.
14+
15+
John Doe. A Book, n.d.
16+
17+
[1] A Book, n.d., 21.
18+
```
19+

0 commit comments

Comments
 (0)