git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: Improved smart quote parsing.

This fixes redering of unmatched quotes. Closes #2555.

commitc73ae81628b77d8b5002e8216650dd8b449768b5 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 24 Nov 2015, 17:20 (11 years ago) parentce55834
1 file changed+13−14
src/Text/Pandoc/Readers/LaTeX.hs+13−14
src/Text/Pandoc/Readers/LaTeX.hs+13−14
@@ -166,26 +166,25 @@ mathChars = (concat <$>) $
166166
167167quoted' :: (Inlines -> Inlines) -> LP String -> LP () -> LP Inlines
168168quoted' f starter ender = do
169− smart <- getOption readerSmart
170169 startchs <- starter
171− ((f . mconcat) <$> manyTill inline ender) <|>
172− lit (if smart
173− then case startchs of
170+ smart <- getOption readerSmart
171+ if smart
172+ then do
173+ ils <- many (notFollowedBy ender >> inline)
174+ (ender >> return (f (mconcat ils))) <|>
175+ lit (case startchs of
174176 "``" -> "“"
175177 "`" -> "‘"
176− _ -> startchs
177− else startchs)
178+ _ -> startchs)
179+ else lit startchs
178180
179181doubleQuote :: LP Inlines
180182doubleQuote = do
181− smart <- getOption readerSmart
182− if smart
183− then quoted' doubleQuoted (try $ string "``") (void $ try $ string "''")
184− <|> quoted' doubleQuoted (string "“") (void $ char '”')
185− -- the following is used by babel for localized quotes:
186− <|> quoted' doubleQuoted (try $ string "\"`") (void $ try $ string "\"'")
187− <|> quoted' doubleQuoted (string "\"") (void $ char '"')
188− else str <$> many1 (oneOf "`'“”\"")
183+ quoted' doubleQuoted (try $ string "``") (void $ try $ string "''")
184+ <|> quoted' doubleQuoted (string "“") (void $ char '”')
185+ -- the following is used by babel for localized quotes:
186+ <|> quoted' doubleQuoted (try $ string "\"`") (void $ try $ string "\"'")
187+ <|> quoted' doubleQuoted (string "\"") (void $ char '"')
189188
190189singleQuote :: LP Inlines
191190singleQuote = do