diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-09-02 21:03:05 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-09-02 21:03:05 -0700 |
commit | 6b286a1d74dd145d08565aaf85e2273ac9e7cef0 (patch) | |
tree | f10ba74265b6d830e8db051a5926c9dbb3f4e14f /src/Text | |
parent | d79242796b5bfa24788d30b239de3b15c0ed326c (diff) | |
download | pandoc-6b286a1d74dd145d08565aaf85e2273ac9e7cef0.tar.gz |
LaTeX reader: don't try to parse includes if raw_tex is set.
When the `raw_tex` extension is set, we just carry through
`\usepackage`, `\input`, etc. verbatim as raw LaTeX.
Closes #5673.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 76a48a364..18bfebabb 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -1152,7 +1152,7 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList -- babel , ("foreignlanguage", foreignlanguage) -- include - , ("input", include "input") + , ("input", rawInlineOr "input" $ include "input") -- soul package , ("ul", underlineSpan <$> tok) -- ulem package @@ -1468,6 +1468,14 @@ paragraph = do then return mempty else return $ para x +rawBlockOr :: PandocMonad m => Text -> LP m Blocks -> LP m Blocks +rawBlockOr name fallback = do + -- if raw_tex allowed, don't process + parseRaw <- extensionEnabled Ext_raw_tex <$> getOption readerExtensions + if parseRaw + then rawBlock "latex" <$> getRawCommand name ("\\" <> name) + else fallback + include :: (PandocMonad m, Monoid a) => Text -> LP m a include name = do skipMany opt @@ -1838,10 +1846,10 @@ blockCommands = M.fromList , ("hyphenblockquote", braced >>= blockquote False . Just . untokenize) , ("hyphenblockcquote", braced >>= blockquote True . Just . untokenize) -- include - , ("include", include "include") - , ("input", include "input") - , ("subfile", include "subfile") - , ("usepackage", include "usepackage") + , ("include", rawBlockOr "include" $ include "include") + , ("input", rawBlockOr "input" $ include "input") + , ("subfile", rawBlockOr "subfile" $ include "subfile") + , ("usepackage", rawBlockOr "usepackage" $ include "usepackage") -- preamble , ("PackageError", mempty <$ (braced >> braced >> braced)) -- epigraph package |