aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs13
-rw-r--r--test/command/ifstrequal.md10
2 files changed, 23 insertions, 0 deletions
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"]]
+```