LaTeX reader: support etoolbox's ifstrequal.

This commit is contained in:
John MacFarlane 2017-07-24 11:16:43 +02:00
parent e7876d4320
commit 329b61ff5c
2 changed files with 23 additions and 0 deletions

View file

@ -1316,8 +1316,21 @@ inlineCommands = M.fromList $
, ("faClose", lit "\10007")
-- xspace
, ("xspace", doxspace)
-- etoolbox
, ("ifstrequal", ifstrequal)
]
ifstrequal :: PandocMonad m => LP m Inlines
ifstrequal = do
str1 <- tok
str2 <- tok
ifequal <- braced
ifnotequal <- braced
if str1 == str2
then getInput >>= setInput . (ifequal ++)
else getInput >>= setInput . (ifnotequal ++)
return mempty
ttfamily :: PandocMonad m => LP m Inlines
ttfamily = (code . stringify . toList) <$> tok

View file

@ -0,0 +1,10 @@
```
% pandoc -f latex -t native
\ifstrequal{a}{b}{yes}{\emph{no}}
\newcommand{\h}[1]{\ifstrequal{#1}{a}{\'a}{#1}}
\h{a}
\h{b}
^D
[Para [Emph [Str "no"]]
,Para [Str "\225",SoftBreak,Str "b"]]
```