Skip to content

Commit

Permalink
LaTeX reader: add support for LaTeX subfiles package.
Browse files Browse the repository at this point in the history
Closes #3530.
  • Loading branch information
schrieveslaach authored and jgm committed Mar 27, 2017
1 parent e3472f0 commit 49d7244
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Text/Pandoc/Readers/LaTeX.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,7 @@ include = do
char '\\'
name <- try (string "include")
<|> try (string "input")
<|> try (string "subfile")
<|> string "usepackage"
-- skip options
skipMany $ try $ char '[' *> manyTill anyChar (char ']')
Expand Down
22 changes: 22 additions & 0 deletions test/command/3530.md
Original file line number Diff line number Diff line change
@@ -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."]]
```
8 changes: 8 additions & 0 deletions test/command/sub-file-chapter-1.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
\documentclass[main.tex]{subfiles}
\begin{document}

\section{Chapter 1}

This is Chapter 1, provided in a sub file.

\end{document}
8 changes: 8 additions & 0 deletions test/command/sub-file-chapter-2.tex
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit 49d7244

Please sign in to comment.