git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: fix bugs omitting raw tex.

The default is `-raw_tex`, so no raw tex should result unless we explicitly say `+raw_tex`. Previously some raw commands did make it through. Closes #4527.

commitb806bff5b44abff96a1400f23448f986d238bff1 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 7 Oct 2018, 12:21 (8 years ago) parent9b481c8
5 files changed+28−10
src/Text/Pandoc/Readers/LaTeX.hs+7−2 test/command/3494.md+1−1 test/command/3577.md−2 test/command/3983.md+3−3 test/command/4527.md+17−2
src/Text/Pandoc/Readers/LaTeX.hs+7−2
@@ -1644,7 +1644,9 @@ blockCommand = try $ do
16441644 let names = ordNub [name', name]
16451645 let rawDefiniteBlock = do
16461646 guard $ isBlockCommand name
1647− rawBlock "latex" <$> getRawCommand name (txt <> star)
1647+ rawcontents <- getRawCommand name (txt <> star)
1648+ (guardEnabled Ext_raw_tex >> return (rawBlock "latex" rawcontents))
1649+ <|> ignore rawcontents
16481650 -- heuristic: if it could be either block or inline, we
16491651 -- treat it if block if we have a sequence of block
16501652 -- commands followed by a newline. But we stop if we
@@ -1656,7 +1658,10 @@ blockCommand = try $ do
16561658 guard $ "start" `T.isPrefixOf` n
16571659 let rawMaybeBlock = try $ do
16581660 guard $ not $ isInlineCommand name
1659− curr <- rawBlock "latex" <$> getRawCommand name (txt <> star)
1661+ rawcontents <- getRawCommand name (txt <> star)
1662+ curr <- (guardEnabled Ext_raw_tex >>
1663+ return (rawBlock "latex" rawcontents))
1664+ <|> ignore rawcontents
16601665 rest <- many $ notFollowedBy startCommand *> blockCommand
16611666 lookAhead $ blankline <|> startCommand
16621667 return $ curr <> mconcat rest
test/command/3494.md+1−1
@@ -25,7 +25,7 @@
2525<td style="text-align: left;">thank you</td>
2626</tr>
2727<tr class="odd">
28−<td style="text-align: right;"><p><em>blah</em></p></td>
28+<td style="text-align: right;"><em>blah</em></td>
2929<td style="text-align: left;"><em>blah</em></td>
3030<td style="text-align: left;"><em>blah</em></td>
3131</tr>
test/command/3577.md−2
@@ -15,11 +15,9 @@
1515 \caption{Subfigure with Subfloat}
1616\end{figure}
1717^D
18−
1918<figure>
2019<img src="img1.jpg" alt="Caption 1" /><figcaption>Caption 1</figcaption>
2120</figure>
22−
2321<figure>
2422<img src="img2.jpg" alt="Caption 2" /><figcaption>Caption 2</figcaption>
2523</figure>
test/command/3983.md+3−3
@@ -1,5 +1,5 @@
11```
2−pandoc -f latex -t native
2+pandoc -f latex+raw_tex -t native
33\def\filename@area{foo:bar:baz}
44\makeatletter
55\graphicspath\expandafter{\expandafter{\filename@area}}%
@@ -10,7 +10,7 @@ pandoc -f latex -t native
1010```
1111
1212```
13−pandoc -f latex -t native
13+pandoc -f latex+raw_tex -t native
1414\makeatletter
1515 \newcommand\urlfootnote@[1]{\footnote{\url@{#1}}}
1616 \DeclareRobustCommand{\urlfootnote}{\hyper@normalise\urlfootnote@}
@@ -21,7 +21,7 @@ pandoc -f latex -t native
2121```
2222
2323```
24−pandoc -f latex -t native
24+pandoc -f latex+raw_tex -t native
2525\def\foo{bar}
2626\expandafter\bam\foo
2727^D
test/command/4527.md+17−2
@@ -1,7 +1,7 @@
11# Raw TeX blocks in CommonMark with and without raw_tex
22
33```
4−% pandoc -f latex -t commonmark-raw_tex
4+% pandoc -f latex+raw_tex -t commonmark-raw_tex
55\someunknowncommand
66
77Hello.
@@ -10,7 +10,7 @@ Hello.
1010```
1111
1212```
13−% pandoc -f latex -t commonmark+raw_tex
13+% pandoc -f latex+raw_tex -t commonmark+raw_tex
1414\someunknowncommand
1515
1616Hello.
@@ -19,3 +19,18 @@ Hello.
1919
2020Hello.
2121```
22+
23+```
24+% pandoc -f latex -t native
25+\maketitle
26+^D
27+[]
28+```
29+
30+```
31+% pandoc -f latex -t rst
32+\maketitle
33+Hello.
34+^D
35+Hello.
36+```