git.iko.soy/typeable/pandoc
on master help sign in
More smart quote bug fixes:
96919a6fiddlosopher
src/Text/Pandoc/Readers/LaTeX.hs+6−1
@@ -381,7 +381,8 @@ comment = try (do
381-- inline
381-- inline
382--
382--
383
383
384−inline = choice [ strong, emph, ref, lab, code, linebreak, math, ellipses,
384+inline = choice [ strong, emph, ref, lab, code, linebreak, spacer,
385+ math, ellipses,
385 emDash, enDash, hyphen, quoted, apostrophe,
386 emDash, enDash, hyphen, quoted, apostrophe,
386 accentedChar, specialChar, specialInline, escapedChar,
387 accentedChar, specialChar, specialInline, escapedChar,
387 unescapedChar, str, endline, whitespace ] <?> "inline"
388 unescapedChar, str, endline, whitespace ] <?> "inline"
@@ -579,6 +580,10 @@ linebreak = try (do
579 string "\\\\"
580 string "\\\\"
580 return LineBreak)
581 return LineBreak)
581
582
583+spacer = try $ do
584+ string "\\,"
585+ return (Str "")
586+
582str = do
587str = do
583 result <- many1 (noneOf specialChars)
588 result <- many1 (noneOf specialChars)
584 return (Str result)
589 return (Str result)
src/Text/Pandoc/Shared.hs+3−1
@@ -306,12 +306,14 @@ splitByIndices (x:xs) lst =
306 first:(splitByIndices (map (\y -> y - x) xs) rest)
306 first:(splitByIndices (map (\y -> y - x) xs) rest)
307
307
308-- | Normalize a list of inline elements: remove leading and trailing
308-- | Normalize a list of inline elements: remove leading and trailing
309−-- @Space@ elements, and collapse double @Space@s into singles.
309+-- @Space@ elements, collapse double @Space@s into singles, and
310+-- remove empty Str elements.
310normalizeSpaces :: [Inline] -> [Inline]
311normalizeSpaces :: [Inline] -> [Inline]
311normalizeSpaces [] = []
312normalizeSpaces [] = []
312normalizeSpaces list =
313normalizeSpaces list =
313 let removeDoubles [] = []
314 let removeDoubles [] = []
314 removeDoubles (Space:Space:rest) = removeDoubles (Space:rest)
315 removeDoubles (Space:Space:rest) = removeDoubles (Space:rest)
316+ removeDoubles ((Str ""):rest) = removeDoubles rest
315 removeDoubles (x:rest) = x:(removeDoubles rest) in
317 removeDoubles (x:rest) = x:(removeDoubles rest) in
316 let removeLeading [] = []
318 let removeLeading [] = []
317 removeLeading lst = if ((head lst) == Space)
319 removeLeading lst = if ((head lst) == Space)
src/Text/Pandoc/Writers/LaTeX.hs+11−2
@@ -166,6 +166,11 @@ inlineListToLaTeX :: [Block] -- ^ List of note blocks to use in resolving note
166inlineListToLaTeX notes lst =
166inlineListToLaTeX notes lst =
167 concatMap (inlineToLaTeX notes) lst
167 concatMap (inlineToLaTeX notes) lst
168
168
169+isQuoted :: Inline -> Bool
170+isQuoted (Quoted _ _) = True
171+isQuoted Apostrophe = True
172+isQuoted _ = False
173+
169-- | Convert inline element to LaTeX
174-- | Convert inline element to LaTeX
170inlineToLaTeX :: [Block] -- ^ List of note blocks to use in resolving note refs
175inlineToLaTeX :: [Block] -- ^ List of note blocks to use in resolving note refs
171 -> Inline -- ^ Inline to convert
176 -> Inline -- ^ Inline to convert
@@ -178,9 +183,13 @@ inlineToLaTeX notes (Code str) = "\\verb" ++ [chr] ++ stuffing ++ [chr]
178 where stuffing = str
183 where stuffing = str
179 chr = ((enumFromTo '!' '~') \\ stuffing) !! 0
184 chr = ((enumFromTo '!' '~') \\ stuffing) !! 0
180inlineToLaTeX notes (Quoted SingleQuote lst) =
185inlineToLaTeX notes (Quoted SingleQuote lst) =
186+ let s1 = if (not (null lst)) && (isQuoted (head lst)) then "\\," else ""
187+ s2 = if (not (null lst)) && (isQuoted (last lst)) then "\\," else "" in
181− "`" ++ inlineListToLaTeX notes lst ++ "'"
188+ "`" ++ s1 ++ inlineListToLaTeX notes lst ++ s2 ++ "'"
182inlineToLaTeX notes (Quoted DoubleQuote lst) =
189inlineToLaTeX notes (Quoted DoubleQuote lst) =
190+ let s1 = if (not (null lst)) && (isQuoted (head lst)) then "\\," else ""
191+ s2 = if (not (null lst)) && (isQuoted (last lst)) then "\\," else "" in
183− "``" ++ inlineListToLaTeX notes lst ++ "''"
192+ "``" ++ s1 ++ inlineListToLaTeX notes lst ++ s2 ++ "''"
184inlineToLaTeX notes Apostrophe = "'"
193inlineToLaTeX notes Apostrophe = "'"
185inlineToLaTeX notes EmDash = "---"
194inlineToLaTeX notes EmDash = "---"
186inlineToLaTeX notes EnDash = "--"
195inlineToLaTeX notes EnDash = "--"
tests/writer.latex+2−2
@@ -377,13 +377,13 @@ This is code: \verb!>!, \verb!$!, \verb!\!, \verb!\$!, \verb!<html>!.
377
377
378\section{Smart quotes, ellipses, dashes}
378\section{Smart quotes, ellipses, dashes}
379
379
380−``Hello,'' said the spider. ```Shelob' is my name.''
380+``Hello,'' said the spider. ``\,`Shelob' is my name.''
381
381
382`A', `B', and `C' are letters.
382`A', `B', and `C' are letters.
383
383
384`Oak,' `elm,' and `beech' are names of trees. So is `pine.'
384`Oak,' `elm,' and `beech' are names of trees. So is `pine.'
385
385
386−`He said, ``I want to go.''' Were you alive in the 70's?
386+`He said, ``I want to go.''\,' Were you alive in the 70's?
387
387
388Here is some quoted `\verb!code!' and a ``\href{http://example.com/?foo=1&bar=2}{quoted link}''.
388Here is some quoted `\verb!code!' and a ``\href{http://example.com/?foo=1&bar=2}{quoted link}''.
389
389