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.
This commit is contained in:
parent
d79242796b
commit
6b286a1d74
2 changed files with 15 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -14,9 +14,6 @@
|
|||
\subfile{command/sub-file-chapter-1}
|
||||
\subfile{command/sub-file-chapter-2}
|
||||
^D
|
||||
[Header 1 ("chapter-1",[],[]) [Str "Chapter",Space,Str "1"]
|
||||
,Para [Str "This",Space,Str "is",Space,Str "Chapter",Space,Str "1,",Space,Str "provided",Space,Str "in",Space,Str "a",Space,Str "sub",Space,Str "file."]
|
||||
,Header 1 ("chapter-2",[],[]) [Str "Chapter",Space,Str "2"]
|
||||
,Para [Str "This",Space,Str "is",Space,Str "Chapter",Space,Str "2,",Space,Str "provided",Space,Str "in",Space,Str "a",Space,Str "second",Space,Str "sub",Space,Str "file."]]
|
||||
|
||||
[RawBlock (Format "latex") "\\subfile{command/sub-file-chapter-1}"
|
||||
,RawBlock (Format "latex") "\\subfile{command/sub-file-chapter-2}"]
|
||||
```
|
||||
|
|
Loading…
Add table
Reference in a new issue