git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: Improved smart quote parsing.
c73ae81John MacFarlane
src/Text/Pandoc/Readers/LaTeX.hs+13−14
@@ -166,26 +166,25 @@ mathChars = (concat <$>) $
166
166
167quoted' :: (Inlines -> Inlines) -> LP String -> LP () -> LP Inlines
167quoted' :: (Inlines -> Inlines) -> LP String -> LP () -> LP Inlines
168quoted' f starter ender = do
168quoted' f starter ender = do
169− smart <- getOption readerSmart
170 startchs <- starter
169 startchs <- starter
171− ((f . mconcat) <$> manyTill inline ender) <|>
170+ smart <- getOption readerSmart
172− lit (if smart
171+ if smart
172+ then do
173+ ils <- many (notFollowedBy ender >> inline)
174+ (ender >> return (f (mconcat ils))) <|>
173− then case startchs of
175+ lit (case startchs of
174 "``" -> "“"
176 "``" -> "“"
175 "`" -> "‘"
177 "`" -> "‘"
176− _ -> startchs
178+ _ -> startchs)
177− else startchs)
179+ else lit startchs
178
180
179doubleQuote :: LP Inlines
181doubleQuote :: LP Inlines
180doubleQuote = do
182doubleQuote = do
181− smart <- getOption readerSmart
182− if smart
183− then quoted' doubleQuoted (try $ string "``") (void $ try $ string "''")
183+ quoted' doubleQuoted (try $ string "``") (void $ try $ string "''")
184− <|> quoted' doubleQuoted (string "“") (void $ char '”')
184+ <|> quoted' doubleQuoted (string "“") (void $ char '”')
185− -- the following is used by babel for localized quotes:
185+ -- the following is used by babel for localized quotes:
186− <|> quoted' doubleQuoted (try $ string "\"`") (void $ try $ string "\"'")
186+ <|> quoted' doubleQuoted (try $ string "\"`") (void $ try $ string "\"'")
187− <|> quoted' doubleQuoted (string "\"") (void $ char '"')
187+ <|> quoted' doubleQuoted (string "\"") (void $ char '"')
188− else str <$> many1 (oneOf "`'“”\"")
189
188
190singleQuote :: LP Inlines
189singleQuote :: LP Inlines
191singleQuote = do
190singleQuote = do