From 329b61ff5cbad6297d1ceea5da7f045613e27ec5 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 24 Jul 2017 11:16:43 +0200 Subject: LaTeX reader: support etoolbox's ifstrequal. --- src/Text/Pandoc/Readers/LaTeX.hs | 13 +++++++++++++ test/command/ifstrequal.md | 10 ++++++++++ 2 files changed, 23 insertions(+) create mode 100644 test/command/ifstrequal.md diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 44be8dea3..494f532a1 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -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 diff --git a/test/command/ifstrequal.md b/test/command/ifstrequal.md new file mode 100644 index 000000000..4ad04d2e1 --- /dev/null +++ b/test/command/ifstrequal.md @@ -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"]] +``` -- cgit v1.2.3