git.iko.soy/typeable/pandoc
on master help sign in
Fix for bug in parsing `\include` in markdown.
34b229dJohn MacFarlane
src/Text/Pandoc/Readers/LaTeX.hs+10−1
@@ -286,6 +286,12 @@ rawLaTeXBlock :: (PandocMonad m, HasMacros s, HasReaderOptions s)
286rawLaTeXBlock = do
286rawLaTeXBlock = do
287 lookAhead (try (char '\\' >> letter))
287 lookAhead (try (char '\\' >> letter))
288 snd <$> (rawLaTeXParser False macroDef blocks
288 snd <$> (rawLaTeXParser False macroDef blocks
289+ <|> (rawLaTeXParser True
290+ (do choice (map controlSeq
291+ ["include", "input", "subfile", "usepackage"])
292+ skipMany opt
293+ braced
294+ return mempty) blocks)
289 <|> rawLaTeXParser True
295 <|> rawLaTeXParser True
290 (environment <|> blockCommand)
296 (environment <|> blockCommand)
291 (mconcat <$> (many (block <|> beginOrEndCommand))))
297 (mconcat <$> (many (block <|> beginOrEndCommand))))
@@ -308,7 +314,10 @@ rawLaTeXInline :: (PandocMonad m, HasMacros s, HasReaderOptions s)
308 => ParserT String s m String
314 => ParserT String s m String
309rawLaTeXInline = do
315rawLaTeXInline = do
310 lookAhead (try (char '\\' >> letter))
316 lookAhead (try (char '\\' >> letter))
317+ snd <$> ( rawLaTeXParser True
318+ (mempty <$ (controlSeq "input" >> skipMany opt >> braced))
319+ inlines
311− snd <$> rawLaTeXParser True (inlineEnvironment <|> inlineCommand') inlines
320+ <|> rawLaTeXParser True (inlineEnvironment <|> inlineCommand') inlines)
312
321
313inlineCommand :: PandocMonad m => ParserT String ParserState m Inlines
322inlineCommand :: PandocMonad m => ParserT String ParserState m Inlines
314inlineCommand = do
323inlineCommand = do
test/command/4781.mdnew file+22
@@ -0,0 +1,22 @@
1+```
2+% pandoc -t native
3+Markdown parsed *here*
4+
5+\include{command/bar}
6+
7+*But not here*
8+^D
9+[Para [Str "Markdown",Space,Str "parsed",Space,Emph [Str "here"]]
10+,RawBlock (Format "latex") "\\include{command/bar}"
11+,Para [Emph [Str "But",Space,Str "not",Space,Str "here"]]]
12+```
13+
14+```
15+% pandoc -t native
16+*here* \input{command/bar}
17+
18+*But not here*
19+^D
20+[Para [Emph [Str "here"],Space,RawInline (Format "tex") "\\input{command/bar}"]
21+,Para [Emph [Str "But",Space,Str "not",Space,Str "here"]]]
22+```