aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-12-17 11:47:28 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2018-12-17 11:47:28 -0800
commit595e954c9bd5bc58ed856495b00bb7aba38660b6 (patch)
tree187174fa759ea4f8581edd0ead6841c510c35513
parent404e96761a9301e750a332524137639e204e44d0 (diff)
downloadpandoc-595e954c9bd5bc58ed856495b00bb7aba38660b6.tar.gz
LaTeX reader: Support `\DeclareMathOperator`.
Closes #5149.
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 42a0bc04c..147527d2b 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1557,6 +1557,7 @@ newcommand = do
Tok _ (CtrlSeq mtype) _ <- controlSeq "newcommand" <|>
controlSeq "renewcommand" <|>
controlSeq "providecommand" <|>
+ controlSeq "DeclareMathOperator" <|>
controlSeq "DeclareRobustCommand"
withVerbatimMode $ do
Tok _ (CtrlSeq name) txt <- do
@@ -1569,7 +1570,16 @@ newcommand = do
spaces
optarg <- option Nothing $ Just <$> try bracketedToks
spaces
- contents <- bracedOrToken
+ contents' <- bracedOrToken
+ let contents =
+ case mtype of
+ "DeclareMathOperator" ->
+ Tok pos (CtrlSeq "mathop") "\\mathop"
+ : Tok pos (CtrlSeq "mathrm") "\\mathrm"
+ : Tok pos Symbol "{"
+ : (contents' ++
+ [ Tok pos Symbol "}" ])
+ _ -> contents'
when (mtype == "newcommand") $ do
macros <- sMacros <$> getState
case M.lookup name macros of