diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-10-07 12:21:43 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-10-07 12:21:43 -0700 |
commit | b806bff5b44abff96a1400f23448f986d238bff1 (patch) | |
tree | 52b7bd16bbd3e7023da1b0f4d809dca5efeca5d8 | |
parent | 9b481c8787f2c6e69bce3bb264b4d4f1fe8ed78e (diff) | |
download | pandoc-b806bff5b44abff96a1400f23448f986d238bff1.tar.gz |
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.
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 9 | ||||
-rw-r--r-- | test/command/3494.md | 2 | ||||
-rw-r--r-- | test/command/3577.md | 2 | ||||
-rw-r--r-- | test/command/3983.md | 6 | ||||
-rw-r--r-- | test/command/4527.md | 19 |
5 files changed, 28 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 7c5619165..4ced829cc 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -1644,7 +1644,9 @@ blockCommand = try $ do let names = ordNub [name', name] let rawDefiniteBlock = do guard $ isBlockCommand name - rawBlock "latex" <$> getRawCommand name (txt <> star) + rawcontents <- getRawCommand name (txt <> star) + (guardEnabled Ext_raw_tex >> return (rawBlock "latex" rawcontents)) + <|> ignore rawcontents -- heuristic: if it could be either block or inline, we -- treat it if block if we have a sequence of block -- commands followed by a newline. But we stop if we @@ -1656,7 +1658,10 @@ blockCommand = try $ do guard $ "start" `T.isPrefixOf` n let rawMaybeBlock = try $ do guard $ not $ isInlineCommand name - curr <- rawBlock "latex" <$> getRawCommand name (txt <> star) + rawcontents <- getRawCommand name (txt <> star) + curr <- (guardEnabled Ext_raw_tex >> + return (rawBlock "latex" rawcontents)) + <|> ignore rawcontents rest <- many $ notFollowedBy startCommand *> blockCommand lookAhead $ blankline <|> startCommand return $ curr <> mconcat rest diff --git a/test/command/3494.md b/test/command/3494.md index 249973fb3..7c480fde6 100644 --- a/test/command/3494.md +++ b/test/command/3494.md @@ -25,7 +25,7 @@ <td style="text-align: left;">thank you</td> </tr> <tr class="odd"> -<td style="text-align: right;"><p><em>blah</em></p></td> +<td style="text-align: right;"><em>blah</em></td> <td style="text-align: left;"><em>blah</em></td> <td style="text-align: left;"><em>blah</em></td> </tr> diff --git a/test/command/3577.md b/test/command/3577.md index ca9dba97c..dc88937e9 100644 --- a/test/command/3577.md +++ b/test/command/3577.md @@ -15,11 +15,9 @@ \caption{Subfigure with Subfloat} \end{figure} ^D - <figure> <img src="img1.jpg" alt="Caption 1" /><figcaption>Caption 1</figcaption> </figure> - <figure> <img src="img2.jpg" alt="Caption 2" /><figcaption>Caption 2</figcaption> </figure> diff --git a/test/command/3983.md b/test/command/3983.md index 7eaeb99f0..5d83941e7 100644 --- a/test/command/3983.md +++ b/test/command/3983.md @@ -1,5 +1,5 @@ ``` -pandoc -f latex -t native +pandoc -f latex+raw_tex -t native \def\filename@area{foo:bar:baz} \makeatletter \graphicspath\expandafter{\expandafter{\filename@area}}% @@ -10,7 +10,7 @@ pandoc -f latex -t native ``` ``` -pandoc -f latex -t native +pandoc -f latex+raw_tex -t native \makeatletter \newcommand\urlfootnote@[1]{\footnote{\url@{#1}}} \DeclareRobustCommand{\urlfootnote}{\hyper@normalise\urlfootnote@} @@ -21,7 +21,7 @@ pandoc -f latex -t native ``` ``` -pandoc -f latex -t native +pandoc -f latex+raw_tex -t native \def\foo{bar} \expandafter\bam\foo ^D diff --git a/test/command/4527.md b/test/command/4527.md index 984333559..2f54fca60 100644 --- a/test/command/4527.md +++ b/test/command/4527.md @@ -1,7 +1,7 @@ # Raw TeX blocks in CommonMark with and without raw_tex ``` -% pandoc -f latex -t commonmark-raw_tex +% pandoc -f latex+raw_tex -t commonmark-raw_tex \someunknowncommand Hello. @@ -10,7 +10,7 @@ Hello. ``` ``` -% pandoc -f latex -t commonmark+raw_tex +% pandoc -f latex+raw_tex -t commonmark+raw_tex \someunknowncommand Hello. @@ -19,3 +19,18 @@ Hello. Hello. ``` + +``` +% pandoc -f latex -t native +\maketitle +^D +[] +``` + +``` +% pandoc -f latex -t rst +\maketitle +Hello. +^D +Hello. +``` |