summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2024-03-09 08:59:46 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2024-03-09 12:53:13 -0800
commit626ffd74b4cb0038eb7d4ee638486f156753da1c (patch)
tree3d62f17a99f00c7bb0a73b0201f146ac63e7545d
parenteca9ad1009127ac4f4a0c9e21dd45562d676aae2 (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.hs6
-rw-r--r--test/command/9517.md34
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 ( "" , [] , [] ) [])
+]
+```