Skip to content

🐛 fix(latex): keep array column spec pipes when escaping - #9

Open
alaasumrain wants to merge 1 commit into
lobehub:mainfrom
alaasumrain:fix/array-column-spec-pipes
Open

alaasumrain wants to merge 1 commit into
lobehub:mainfrom
alaasumrain:fix/array-column-spec-pipes

Conversation

@alaasumrain

Copy link
Copy Markdown

Problem

escapeLatexPipes replaces every unescaped | inside a formula with \vert{}. That includes the column spec of an array, so

$$\begin{array}{c|c|c} … \end{array}$$

becomes \begin{array}{c\vert{}c\vert{}c}, and KaTeX fails with Unknown column alignment: \vert. Any array or table with vertical rules renders as a red error.

Fix

replaceUnescapedPipes sets aside the column spec of array, subarray and tabular before swapping pipes, then puts it back. Pipes in the formula body are still escaped, so $\{x | x > 0\}$ behaves exactly as before.

Test

Added a case to src/latex.test.ts: an array whose spec keeps {c|c} while a | in its body still becomes \vert{}. The existing pipe tests are unchanged.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant