diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2024-03-09 08:59:46 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2024-03-09 12:53:13 -0800 |
| commit | 626ffd74b4cb0038eb7d4ee638486f156753da1c (patch) | |
| tree | 3d62f17a99f00c7bb0a73b0201f146ac63e7545d | |
| parent | eca9ad1009127ac4f4a0c9e21dd45562d676aae2 (diff) | |
LaTeX reader: Make `withRaw` work inside `parseFromToks`.
This is needed for raw environments to work inside table cells.
Closes #9517.
| -rw-r--r-- | src/Text/Pandoc/Readers/LaTeX/Parsing.hs | 6 | ||||
| -rw-r--r-- | test/command/9517.md | 34 |
2 files changed, 39 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs index c2217f809..388c6fa09 100644 --- a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs +++ b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs @@ -490,7 +490,11 @@ parseFromToks parser toks = do case toks of Tok pos _ _ : _ -> setPosition pos _ -> return () - result <- disablingWithRaw parser + -- we ignore existing raw tokens maps (see #9517) + oldRawTokens <- sRawTokens <$> getState + updateState $ \st -> st{ sRawTokens = mempty } + result <- parser + updateState $ \st -> st{ sRawTokens = oldRawTokens } setInput oldInput setPosition oldpos return result diff --git a/test/command/9517.md b/test/command/9517.md new file mode 100644 index 000000000..bc2c41e87 --- /dev/null +++ b/test/command/9517.md @@ -0,0 +1,34 @@ +``` +% pandoc -f latex+raw_tex -t native +\begin{tabular}{l} +\begin{theorem} +Cats +\end{theorem} +\end{tabular} +^D +[ Table + ( "" , [] , [] ) + (Caption Nothing []) + [ ( AlignLeft , ColWidthDefault ) ] + (TableHead ( "" , [] , [] ) []) + [ TableBody + ( "" , [] , [] ) + (RowHeadColumns 0) + [] + [ Row + ( "" , [] , [] ) + [ Cell + ( "" , [] , [] ) + AlignDefault + (RowSpan 1) + (ColSpan 1) + [ RawBlock + (Format "latex") + "\\begin{theorem}\nCats\n\\end{theorem}" + ] + ] + ] + ] + (TableFoot ( "" , [] , [] ) []) +] +``` |
