diff options
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 11 | ||||
-rw-r--r-- | test/command/4781.md | 22 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index c15312cd8..1dd31d402 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -286,6 +286,12 @@ rawLaTeXBlock :: (PandocMonad m, HasMacros s, HasReaderOptions s) rawLaTeXBlock = do lookAhead (try (char '\\' >> letter)) snd <$> (rawLaTeXParser False macroDef blocks + <|> (rawLaTeXParser True + (do choice (map controlSeq + ["include", "input", "subfile", "usepackage"]) + skipMany opt + braced + return mempty) blocks) <|> rawLaTeXParser True (environment <|> blockCommand) (mconcat <$> (many (block <|> beginOrEndCommand)))) @@ -308,7 +314,10 @@ rawLaTeXInline :: (PandocMonad m, HasMacros s, HasReaderOptions s) => ParserT String s m String rawLaTeXInline = do lookAhead (try (char '\\' >> letter)) - snd <$> rawLaTeXParser True (inlineEnvironment <|> inlineCommand') inlines + snd <$> ( rawLaTeXParser True + (mempty <$ (controlSeq "input" >> skipMany opt >> braced)) + inlines + <|> rawLaTeXParser True (inlineEnvironment <|> inlineCommand') inlines) inlineCommand :: PandocMonad m => ParserT String ParserState m Inlines inlineCommand = do diff --git a/test/command/4781.md b/test/command/4781.md new file mode 100644 index 000000000..7dc973c7c --- /dev/null +++ b/test/command/4781.md @@ -0,0 +1,22 @@ +``` +% pandoc -t native +Markdown parsed *here* + +\include{command/bar} + +*But not here* +^D +[Para [Str "Markdown",Space,Str "parsed",Space,Emph [Str "here"]] +,RawBlock (Format "latex") "\\include{command/bar}" +,Para [Emph [Str "But",Space,Str "not",Space,Str "here"]]] +``` + +``` +% pandoc -t native +*here* \input{command/bar} + +*But not here* +^D +[Para [Emph [Str "here"],Space,RawInline (Format "tex") "\\input{command/bar}"] +,Para [Emph [Str "But",Space,Str "not",Space,Str "here"]]] +``` |