From 8f60176511d006cc1c9fb8146f4e38cb9b760dc6 Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Wed, 15 Dec 2010 12:06:14 +0100 Subject: 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. --- src/Text/Pandoc/Writers/LaTeX.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 9ddfc8b84..ca7446994 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -33,7 +33,7 @@ import Text.Pandoc.Shared import Text.Pandoc.Templates import Text.Printf ( printf ) import Data.List ( (\\), isSuffixOf, isPrefixOf, intersperse, intercalate ) -import Data.Char ( toLower ) +import Data.Char ( toLower, isPunctuation ) import Control.Monad.State import Text.PrettyPrint.HughesPJ hiding ( Str ) import System.FilePath (dropExtension) @@ -428,8 +428,12 @@ citeCommand c p s k = do citeArguments :: [Inline] -> [Inline] -> String -> State WriterState Doc citeArguments p s k = do + let s' = case s of + (Str (x:[]) : r) | isPunctuation x -> dropWhile (== Space) r + (Str (x:xs) : r) | isPunctuation x -> Str xs : r + _ -> s pdoc <- inlineListToLaTeX p - sdoc <- inlineListToLaTeX s + sdoc <- inlineListToLaTeX s' let optargs = case (isEmpty pdoc, isEmpty sdoc) of (True, True ) -> empty (True, False) -> brackets sdoc -- cgit v1.2.3