git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: don't let `\egroup` match `{`.

`braced` now actually requires nested braces. Otherwise some legitimate command and environment definitions can break (see test/command/tex-group.md).

commite752669e50815b0c1bef62fc5b1de95c33317f89 authorJohn MacFarlane <jgm@berkeley.edu> dateThu 31 Jan 2019, 22:50 (8 years ago) parent7c424b3
2 files changed+15−3
src/Text/Pandoc/Readers/LaTeX/Parsing.hs+3−3 test/command/tex-group.md+12
src/Text/Pandoc/Readers/LaTeX/Parsing.hs+3−3
@@ -612,19 +612,19 @@ braced' :: PandocMonad m => LP m Tok -> Int -> LP m [Tok]
612612braced' getTok n =
613613 handleEgroup <|> handleBgroup <|> handleOther
614614 where handleEgroup = do
615− t <- egroup
615+ t <- symbol '}'
616616 if n == 1
617617 then return []
618618 else (t:) <$> braced' getTok (n - 1)
619619 handleBgroup = do
620− t <- bgroup
620+ t <- symbol '{'
621621 (t:) <$> braced' getTok (n + 1)
622622 handleOther = do
623623 t <- getTok
624624 (t:) <$> braced' getTok n
625625
626626braced :: PandocMonad m => LP m [Tok]
627−braced = bgroup *> braced' anyTok 1
627+braced = symbol '{' *> braced' anyTok 1
628628
629629-- URLs require special handling, because they can contain %
630630-- characters. So we retonenize comments as we go...
test/command/tex-group.mdnew file+12
@@ -0,0 +1,12 @@
1+```
2+% pandoc -f latex -t html
3+\newenvironment{foo}%
4+{\emph\bgroup}%
5+{\egroup}
6+
7+\begin{foo}
8+hi
9+\end{foo}
10+^D
11+<p><em>hi</em></p>
12+```