LaTeX reader: add support for LaTeX subfiles package.

Closes #3530.
This commit is contained in:
schrieveslaach 2017-03-27 21:20:27 +02:00 committed by John MacFarlane
parent e3472f0df5
commit 49d72444d7
4 changed files with 39 additions and 0 deletions

View file

@ -1008,6 +1008,7 @@ include = do
char '\\' char '\\'
name <- try (string "include") name <- try (string "include")
<|> try (string "input") <|> try (string "input")
<|> try (string "subfile")
<|> string "usepackage" <|> string "usepackage"
-- skip options -- skip options
skipMany $ try $ char '[' *> manyTill anyChar (char ']') skipMany $ try $ char '[' *> manyTill anyChar (char ']')

22
test/command/3530.md Normal file
View file

@ -0,0 +1,22 @@
```
% pandoc -f latex -t native
\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."]]
```
```
% pandoc -flatex+raw_tex -t native
\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."]]
```

View file

@ -0,0 +1,8 @@
\documentclass[main.tex]{subfiles}
\begin{document}
\section{Chapter 1}
This is Chapter 1, provided in a sub file.
\end{document}

View file

@ -0,0 +1,8 @@
\documentclass[main.tex]{subfiles}
\begin{document}
\section{Chapter 2}
This is Chapter 2, provided in a second sub file.
\end{document}