git.iko.soy/typeable/pandoc
on master help sign in
Remove punctuation at start of suffix for natbib and biblatex output.

This is necessary as the latex citation commands include there own punctuation, which resulted in doubled commas for markdown documents where citeproc output works correctly.

commit8f60176511d006cc1c9fb8146f4e38cb9b760dc6 authorNathan Gass <gass@search.ch> dateWed 15 Dec 2010, 12:06 (16 years ago) parent43fee5e
4 files changed+15−11
src/Text/Pandoc/Writers/LaTeX.hs+6−2 tests/biblatex-citations.latex+3−3 tests/markdown-citations.txt+3−3 tests/natbib-citations.latex+3−3
src/Text/Pandoc/Writers/LaTeX.hs+6−2
@@ -33,7 +33,7 @@ import Text.Pandoc.Shared
3333import Text.Pandoc.Templates
3434import Text.Printf ( printf )
3535import Data.List ( (\\), isSuffixOf, isPrefixOf, intersperse, intercalate )
36−import Data.Char ( toLower )
36+import Data.Char ( toLower, isPunctuation )
3737import Control.Monad.State
3838import Text.PrettyPrint.HughesPJ hiding ( Str )
3939import System.FilePath (dropExtension)
@@ -428,8 +428,12 @@ citeCommand c p s k = do
428428
429429citeArguments :: [Inline] -> [Inline] -> String -> State WriterState Doc
430430citeArguments p s k = do
431+ let s' = case s of
432+ (Str (x:[]) : r) | isPunctuation x -> dropWhile (== Space) r
433+ (Str (x:xs) : r) | isPunctuation x -> Str xs : r
434+ _ -> s
431435 pdoc <- inlineListToLaTeX p
432− sdoc <- inlineListToLaTeX s
436+ sdoc <- inlineListToLaTeX s'
433437 let optargs = case (isEmpty pdoc, isEmpty sdoc) of
434438 (True, True ) -> empty
435439 (True, False) -> brackets sdoc
tests/biblatex-citations.latex+3−3
@@ -39,7 +39,7 @@
3939
4040\item
4141 A citation group
42− \autocites[see][, p.~34--35]{item1}[also][chap. 3]{item3}.
42+ \autocites[see][p.~34--35]{item1}[also][chap. 3]{item3}.
4343
4444\item
4545 Another one \autocite[see][p.~34--35]{item1}.
@@ -50,10 +50,10 @@
5050
5151\item
5252 Citation with a suffix and locator
53− \autocite[, pp.~33, 35--37, and nowhere else]{item1}.
53+ \autocite[pp.~33, 35--37, and nowhere else]{item1}.
5454
5555\item
56− Citation with suffix only \autocite[, and nowhere else]{item1}.
56+ Citation with suffix only \autocite[and nowhere else]{item1}.
5757
5858\item
5959 Now some modifiers.%
tests/markdown-citations.txt+3−3
@@ -14,16 +14,16 @@
1414
1515- In a note.[^1]
1616
17−- A citation group [see @item1, p. 34-35; also @item3 chap. 3].
17+- A citation group [see @item1 p. 34-35; also @item3 chap. 3].
1818
1919- Another one [see @item1 p. 34-35].
2020
2121- And another one in a note.[^2]
2222
2323- Citation with a suffix and locator
24− [@item1, pp. 33, 35-37, and nowhere else].
24+ [@item1 pp. 33, 35-37, and nowhere else].
2525
26−- Citation with suffix only [@item1, and nowhere else].
26+- Citation with suffix only [@item1 and nowhere else].
2727
2828- Now some modifiers.[^3]
2929
tests/natbib-citations.latex+3−3
@@ -40,7 +40,7 @@
4040
4141\item
4242 A citation group
43− \citetext{\citealp[see][, p.~34--35]{item1}; \citealp[also][chap. 3]{item3}}.
43+ \citetext{\citealp[see][p.~34--35]{item1}; \citealp[also][chap. 3]{item3}}.
4444
4545\item
4646 Another one \citep[see][p.~34--35]{item1}.
@@ -52,10 +52,10 @@
5252
5353\item
5454 Citation with a suffix and locator
55− \citep[, pp.~33, 35--37, and nowhere else]{item1}.
55+ \citep[pp.~33, 35--37, and nowhere else]{item1}.
5656
5757\item
58− Citation with suffix only \citep[, and nowhere else]{item1}.
58+ Citation with suffix only \citep[and nowhere else]{item1}.
5959
6060\item
6161 Now some modifiers.%