From 96919a6ac5c21a8b46fbc347a4d815f0c9c89b98 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Wed, 24 Jan 2007 08:14:43 +0000 Subject: More smart quote bug fixes: + LaTeX writer now handles consecutive quotes properly: for example, ``\,`hello'\,'' + LaTeX reader now parses '\,' as empty Str + normalizeSpaces function in Shared now removes empty Str elements + Modified tests accordingly git-svn-id: https://pandoc.googlecode.com/svn/trunk@506 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Writers/LaTeX.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 2badf2f24..d72c915d5 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -166,6 +166,11 @@ inlineListToLaTeX :: [Block] -- ^ List of note blocks to use in resolving note inlineListToLaTeX notes lst = concatMap (inlineToLaTeX notes) lst +isQuoted :: Inline -> Bool +isQuoted (Quoted _ _) = True +isQuoted Apostrophe = True +isQuoted _ = False + -- | Convert inline element to LaTeX inlineToLaTeX :: [Block] -- ^ List of note blocks to use in resolving note refs -> Inline -- ^ Inline to convert @@ -178,9 +183,13 @@ inlineToLaTeX notes (Code str) = "\\verb" ++ [chr] ++ stuffing ++ [chr] where stuffing = str chr = ((enumFromTo '!' '~') \\ stuffing) !! 0 inlineToLaTeX notes (Quoted SingleQuote lst) = - "`" ++ inlineListToLaTeX notes lst ++ "'" + let s1 = if (not (null lst)) && (isQuoted (head lst)) then "\\," else "" + s2 = if (not (null lst)) && (isQuoted (last lst)) then "\\," else "" in + "`" ++ s1 ++ inlineListToLaTeX notes lst ++ s2 ++ "'" inlineToLaTeX notes (Quoted DoubleQuote lst) = - "``" ++ inlineListToLaTeX notes lst ++ "''" + let s1 = if (not (null lst)) && (isQuoted (head lst)) then "\\," else "" + s2 = if (not (null lst)) && (isQuoted (last lst)) then "\\," else "" in + "``" ++ s1 ++ inlineListToLaTeX notes lst ++ s2 ++ "''" inlineToLaTeX notes Apostrophe = "'" inlineToLaTeX notes EmDash = "---" inlineToLaTeX notes EnDash = "--" -- cgit v1.2.3