summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-05-24 21:46:53 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-05-24 21:46:53 +0200
commit1288a50380e01ac50818033a16cc9146f373bdde (patch)
treecee5eaf4f8a19c6465e840885f2eb89a6b90b9ff
parent19d3a2bbe5291dcba0bdba9f6faf0103f5f47245 (diff)
LaTeX reader: parse tikzpicture as raw verbatim environment...
if `raw_tex` extension is selected. Otherwise skip with a warning. This is better than trying to parse it as text! Closes #3692.
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 84758d309..af7c1d9b7 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1031,6 +1031,19 @@ rawEnv name = do
report $ SkippedContent ("\\end{" ++ name ++ "}") pos2
return bs
+rawVerbEnv :: PandocMonad m => String -> LP m Blocks
+rawVerbEnv name = do
+ pos <- getPosition
+ (_, raw) <- withRaw $ verbEnv name
+ let raw' = "\\begin{tikzpicture}" ++ raw
+ exts <- getOption readerExtensions
+ let parseRaw = extensionEnabled Ext_raw_tex exts
+ if parseRaw
+ then return $ rawBlock "latex" raw'
+ else do
+ report $ SkippedContent raw' pos
+ return mempty
+
----
maybeAddExtension :: String -> FilePath -> FilePath
@@ -1200,6 +1213,7 @@ environments = M.fromList
, ("align*", mathEnvWith para (Just "aligned") "align*")
, ("alignat", mathEnvWith para (Just "aligned") "alignat")
, ("alignat*", mathEnvWith para (Just "aligned") "alignat*")
+ , ("tikzpicture", rawVerbEnv "tikzpicture")
]
figure :: PandocMonad m => LP m Blocks