aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-03-09 21:03:54 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-03-09 21:03:54 +0100
commita088d67f0d7212c96f5b59c568f0fc61a1106be4 (patch)
tree4b8957cbc7cc5265b12b4c5087f00b21026ba9b5 /src/Text/Pandoc
parent1ec6a19223a2466075fd4dadd7428d01475f5d77 (diff)
downloadpandoc-a088d67f0d7212c96f5b59c568f0fc61a1106be4.tar.gz
LaTeX reader: Treat `{{xxx}}` the same as `{xxx}`.
Closes #2115.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 60113173d..48266f894 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -147,17 +147,22 @@ egroup = () <$ char '}'
<|> () <$ controlSeq "endgroup"
grouped :: PandocMonad m => Monoid a => LP m a -> LP m a
-grouped parser = try $ bgroup *> (mconcat <$> manyTill parser egroup)
+grouped parser = try $ do
+ bgroup
+ -- first we check for an inner 'grouped', because
+ -- {{a,b}} should be parsed the same as {a,b}
+ try (grouped parser <* egroup)
+ <|> (mconcat <$> manyTill parser egroup)
braced :: PandocMonad m => LP m String
-braced = bgroup *> (concat <$> manyTill
- ( many1 (satisfy (\c -> c /= '\\' && c /= '}' && c /= '{'))
- <|> try (string "\\}")
- <|> try (string "\\{")
- <|> try (string "\\\\")
- <|> ((\x -> "{" ++ x ++ "}") <$> braced)
- <|> count 1 anyChar
- ) egroup)
+braced = grouped chunk
+ where chunk =
+ many1 (satisfy (\c -> c /= '\\' && c /= '}' && c /= '{'))
+ <|> try (string "\\}")
+ <|> try (string "\\{")
+ <|> try (string "\\\\")
+ <|> ((\x -> "{" ++ x ++ "}") <$> braced)
+ <|> count 1 anyChar
bracketed :: PandocMonad m => Monoid a => LP m a -> LP m a
bracketed parser = try $ char '[' *> (mconcat <$> manyTill parser (char ']'))