aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-03-10 09:46:32 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-03-10 09:46:32 +0100
commitc46febaaeef1c203f5bbb88d845ad5554622f609 (patch)
tree18654f772bb8d50d4b9345031b3076e90340ac65
parenta088d67f0d7212c96f5b59c568f0fc61a1106be4 (diff)
downloadpandoc-c46febaaeef1c203f5bbb88d845ad5554622f609.tar.gz
Expand \newenvironment macros.
Closes #987. Depends on still unreleased texmath 0.9.3.
-rw-r--r--pandoc.cabal2
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs22
-rw-r--r--test/command/987.md12
3 files changed, 25 insertions, 11 deletions
diff --git a/pandoc.cabal b/pandoc.cabal
index 2f030054a..8a3995fd0 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -269,7 +269,7 @@ Library
text >= 0.11 && < 1.3,
zip-archive >= 0.2.3.4 && < 0.4,
HTTP >= 4000.0.5 && < 4000.4,
- texmath >= 0.9 && < 0.10,
+ texmath >= 0.9.3 && < 0.10,
xml >= 1.3.12 && < 1.4,
random >= 1 && < 1.2,
extensible-exceptions >= 0.1 && < 0.2,
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 48266f894..7018d2ce3 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -971,17 +971,19 @@ rawEnv name = do
let parseRaw = extensionEnabled Ext_raw_tex exts
rawOptions <- mconcat <$> many rawopt
let beginCommand = "\\begin{" ++ name ++ "}" ++ rawOptions
- unless parseRaw $ do
- pos1 <- getPosition
- report $ SkippedContent beginCommand pos1
+ pos1 <- getPosition
(bs, raw) <- withRaw $ env name blocks
- raw' <- applyMacros' raw
- if parseRaw
- then return $ rawBlock "latex" $ beginCommand ++ raw'
- else do
- pos2 <- getPosition
- report $ SkippedContent ("\\end{" ++ name ++ "}") pos2
- return bs
+ raw' <- applyMacros' $ beginCommand ++ raw
+ if raw' /= beginCommand ++ raw
+ then parseFromString blocks raw'
+ else if parseRaw
+ then return $ rawBlock "latex" $ beginCommand ++ raw'
+ else do
+ unless parseRaw $ do
+ report $ SkippedContent beginCommand pos1
+ pos2 <- getPosition
+ report $ SkippedContent ("\\end{" ++ name ++ "}") pos2
+ return bs
----
diff --git a/test/command/987.md b/test/command/987.md
new file mode 100644
index 000000000..f632231ef
--- /dev/null
+++ b/test/command/987.md
@@ -0,0 +1,12 @@
+```
+pandoc -f latex -t markdown
+\documentclass{article}
+\newenvironment{flubble}{FOO}{BAR}
+\begin{document}
+ \begin{flubble}
+ grr
+ \end{flubble}
+\end{document}
+^D
+FOO grr BAR
+```