aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-11-24 17:20:15 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-11-24 17:20:15 -0800
commitc73ae81628b77d8b5002e8216650dd8b449768b5 (patch)
tree8f8ac5f159f93c6f51c8dfcd73d5520c840a9e0d /src/Text/Pandoc
parentce5583460c9a936a70a05836cb9efb1021c06f2a (diff)
downloadpandoc-c73ae81628b77d8b5002e8216650dd8b449768b5.tar.gz
LaTeX reader: Improved smart quote parsing.
This fixes redering of unmatched quotes. Closes #2555.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 241ac145a..6500cb29f 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -166,26 +166,25 @@ mathChars = (concat <$>) $
quoted' :: (Inlines -> Inlines) -> LP String -> LP () -> LP Inlines
quoted' f starter ender = do
- smart <- getOption readerSmart
startchs <- starter
- ((f . mconcat) <$> manyTill inline ender) <|>
- lit (if smart
- then case startchs of
+ smart <- getOption readerSmart
+ if smart
+ then do
+ ils <- many (notFollowedBy ender >> inline)
+ (ender >> return (f (mconcat ils))) <|>
+ lit (case startchs of
"``" -> "“"
"`" -> "‘"
- _ -> startchs
- else startchs)
+ _ -> startchs)
+ else lit startchs
doubleQuote :: LP Inlines
doubleQuote = do
- smart <- getOption readerSmart
- if smart
- then quoted' doubleQuoted (try $ string "``") (void $ try $ string "''")
- <|> quoted' doubleQuoted (string "“") (void $ char '”')
- -- the following is used by babel for localized quotes:
- <|> quoted' doubleQuoted (try $ string "\"`") (void $ try $ string "\"'")
- <|> quoted' doubleQuoted (string "\"") (void $ char '"')
- else str <$> many1 (oneOf "`'“”\"")
+ quoted' doubleQuoted (try $ string "``") (void $ try $ string "''")
+ <|> quoted' doubleQuoted (string "“") (void $ char '”')
+ -- the following is used by babel for localized quotes:
+ <|> quoted' doubleQuoted (try $ string "\"`") (void $ try $ string "\"'")
+ <|> quoted' doubleQuoted (string "\"") (void $ char '"')
singleQuote :: LP Inlines
singleQuote = do