From 4fce1a63b1ce6faa133645a2c75e7fa3a5d1b948 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 7 Apr 2012 16:16:43 -0700 Subject: LaTeX reader: Handle \bgroup, \egroup, \begingroup, \endgroup. --- src/Text/Pandoc/Readers/LaTeX.hs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index fbd0d464b..cc71b49f2 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -112,18 +112,28 @@ comment = do newline return () +bgroup :: LP () +bgroup = () <$ char '{' + <|> () <$ controlSeq "bgroup" + <|> () <$ controlSeq "begingroup" + +egroup :: LP () +egroup = () <$ char '}' + <|> () <$ controlSeq "egroup" + <|> () <$ controlSeq "endgroup" + grouped :: Monoid a => LP a -> LP a -grouped parser = try $ char '{' *> (mconcat <$> manyTill parser (char '}')) +grouped parser = try $ bgroup *> (mconcat <$> manyTill parser egroup) braced :: LP String -braced = char '{' *> (concat <$> manyTill +braced = bgroup *> (concat <$> manyTill ( many1 (satisfy (\c -> c /= '\\' && c /= '}' && c /= '{')) <|> try (string "\\}") <|> try (string "\\{") <|> try (string "\\\\") <|> ((\x -> "{" ++ x ++ "}") <$> braced) <|> count 1 anyChar - ) (char '}')) + ) egroup) bracketed :: Monoid a => LP a -> LP a bracketed parser = try $ char '[' *> (mconcat <$> manyTill parser (char ']')) -- cgit v1.2.3