git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: add support for LaTeX subfiles package.

Closes #3530.

commit49d72444d7223afe8730e1d7fe2ad881cc132b9c authorschrieveslaach <schrieveslaach@online.de> dateMon 27 Mar 2017, 21:20 (10 years ago) parente3472f0
4 files changed+39
src/Text/Pandoc/Readers/LaTeX.hs+1 test/command/3530.md+22 test/command/sub-file-chapter-1.tex+8 test/command/sub-file-chapter-2.tex+8
src/Text/Pandoc/Readers/LaTeX.hs+1
@@ -1008,6 +1008,7 @@ include = do
10081008 char '\\'
10091009 name <- try (string "include")
10101010 <|> try (string "input")
1011+ <|> try (string "subfile")
10111012 <|> string "usepackage"
10121013 -- skip options
10131014 skipMany $ try $ char '[' *> manyTill anyChar (char ']')
test/command/3530.mdnew file+22
@@ -0,0 +1,22 @@
1+```
2+% pandoc -f latex -t native
3+\subfile{command/sub-file-chapter-1}
4+\subfile{command/sub-file-chapter-2}
5+^D
6+[Header 1 ("chapter-1",[],[]) [Str "Chapter",Space,Str "1"]
7+,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."]
8+,Header 1 ("chapter-2",[],[]) [Str "Chapter",Space,Str "2"]
9+,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."]]
10+```
11+
12+```
13+% pandoc -flatex+raw_tex -t native
14+\subfile{command/sub-file-chapter-1}
15+\subfile{command/sub-file-chapter-2}
16+^D
17+[Header 1 ("chapter-1",[],[]) [Str "Chapter",Space,Str "1"]
18+,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."]
19+,Header 1 ("chapter-2",[],[]) [Str "Chapter",Space,Str "2"]
20+,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."]]
21+
22+```
test/command/sub-file-chapter-1.texnew file+8
@@ -0,0 +1,8 @@
1+\documentclass[main.tex]{subfiles}
2+\begin{document}
3+
4+\section{Chapter 1}
5+
6+This is Chapter 1, provided in a sub file.
7+
8+\end{document}
test/command/sub-file-chapter-2.texnew file+8
@@ -0,0 +1,8 @@
1+\documentclass[main.tex]{subfiles}
2+\begin{document}
3+
4+\section{Chapter 2}
5+
6+This is Chapter 2, provided in a second sub file.
7+
8+\end{document}