aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs18
-rw-r--r--test/command/3530.md7
2 files changed, 15 insertions, 10 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
diff --git a/test/command/3530.md b/test/command/3530.md
index 66393c856..178b36ff0 100644
--- a/test/command/3530.md
+++ b/test/command/3530.md
@@ -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}"]
```