Skip to content

Commit

Permalink
LaTeX reader: Make withRaw work inside parseFromToks.
Browse files Browse the repository at this point in the history
This is needed for raw environments to work inside table cells.

Closes #9517.
  • Loading branch information
jgm committed Mar 9, 2024
1 parent eca9ad1 commit 626ffd7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Text/Pandoc/Readers/LaTeX/Parsing.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions test/command/9517.md
Original file line number Diff line number Diff line change
@@ -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 ( "" , [] , [] ) [])
]
```

0 comments on commit 626ffd7

Please sign in to comment.