git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: make macroDef polymorphic and allow in inline context.

Otherwise we can't parse something like ``` \lowercase{\def\x{Foo}} ``` I have actually seen tex like this in the wild.

commit6f6ad0514d7c5ec6f7177beecb4f2d5ef80100ae authorJohn MacFarlane <jgm@berkeley.edu> dateMon 15 Oct 2018, 11:46 (8 years ago) parente6ee032
2 files changed+5−12
src/Text/Pandoc/Readers/LaTeX.hs+4−10 test/command/ifstrequal.md+1−2
src/Text/Pandoc/Readers/LaTeX.hs+4−10
@@ -1308,13 +1308,7 @@ isBlockCommand s =
13081308
13091309treatAsBlock :: Set.Set Text
13101310treatAsBlock = Set.fromList
1311− [ "let", "def", "DeclareRobustCommand"
1312− , "newcommand", "renewcommand"
1313− , "newenvironment", "renewenvironment"
1314− , "providecommand", "provideenvironment"
1315− -- newcommand, etc. should be parsed by macroDef, but we need this
1316− -- here so these aren't parsed as inline commands to ignore
1317− , "special", "pdfannot", "pdfstringdef"
1311+ [ "special", "pdfannot", "pdfstringdef"
13181312 , "bibliographystyle"
13191313 , "maketitle", "makeindex", "makeglossary"
13201314 , "addcontentsline", "addtocontents", "addtocounter"
@@ -1375,6 +1369,7 @@ inline = (mempty <$ comment)
13751369 <|> (space <$ whitespace)
13761370 <|> (softbreak <$ endline)
13771371 <|> word
1372+ <|> macroDef
13781373 <|> inlineCommand'
13791374 <|> inlineEnvironment
13801375 <|> inlineGroup
@@ -1420,8 +1415,7 @@ end_ t = try (do
14201415preamble :: PandocMonad m => LP m Blocks
14211416preamble = mempty <$ many preambleBlock
14221417 where preambleBlock = spaces1
1423− <|> void macroDef
1424− <|> void blockCommand
1418+ <|> void (macroDef <|> blockCommand)
14251419 <|> void braced
14261420 <|> (notFollowedBy (begin_ "document") >> void anyTok)
14271421
@@ -1484,7 +1478,7 @@ authors = try $ do
14841478 egroup
14851479 addMeta "author" (map trimInlines auths)
14861480
1487−macroDef :: PandocMonad m => LP m Blocks
1481+macroDef :: (Monoid a, PandocMonad m) => LP m a
14881482macroDef =
14891483 mempty <$ ((commandDef <|> environmentDef) <* doMacros)
14901484 where commandDef = do
test/command/ifstrequal.md+1−2
@@ -5,6 +5,5 @@
55\h{a}
66\h{b}
77^D
8−[Para [Emph [Str "no"]]
9−,Para [Str "\225",SoftBreak,Str "b"]]
8+[Para [Emph [Str "no"],SoftBreak,Str "\225",SoftBreak,Str "b"]]
109```