Repository navigation
fix(latex): support the LaTeX control space in math - #64156
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
The fix works. On the base, a math fence containing \ (the formula from #55346) falls back to raw LaTeX in the TUI; with this change it renders. Strict parseLatex now accepts a backslash followed by a space, tab or CRLF and turns each into a single space node. bun test in packages/latex passes and typecheck reports no errors.
The public API is unchanged: the edit only touches an internal symbol table in packages/latex.
No concerns.
rekram1-node
enabled auto-merge (squash)
November 23, 2026 15:03
beyondChang
pushed a commit
to beyondChang/opencode
that referenced
this pull request
Nov 24, 2026
Co-authored-by: Shreyansh Jain <shreyanshjain646@gmail.com>
Contributor
|
Thanks for picking this up and getting it over the line — and for going to the trouble of keeping the original commits and authorship intact. Glad it's in. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Issue for this PR
Closes #55346
Resubmission of #55359, closed by the automated PR cleanup while it waited for review.
The two commits are @shreyanshj10's and unchanged: same SHAs (
7cd5fb2882,35056bfa44), original author and committer, original dates. Nothing was rebased or edited. This branch only re-hosts them because a PR closed by the cleanup bot can only be reopened from the original fork, which I have no way to reach.Type of change
What does this PR do?
A math fence containing
\(backslash-space, the LaTeX control space) printed its raw source instead of rendering.spacingCommandsinpackages/latex/src/symbols.tscovers\,,\:,\;,\!,\quad,\qquad,\enspaceand\thinspace, but not\.readCommandreturns whatever character follows the backslash unchanged when it is not a letter, so\reachesparseCommandas" ", finds no entry in the table, and strict mode throwsUnsupported command \.markdown.tstreats anyLatexParseErroras "keep the source", so the whole block falls back to unrendered code.This adds the missing entry with width 1, which is what
\;and\enspacealready use for a space. A backslash before a tab, a carriage return or a newline reaches the same table as"\t","\r"and"\n"; KaTeX collapses a backslash followed by any of space, tab, CR or LF into the same control-space token (controlSpaceRegexStringin itsLexer), so all four are added and a CRLF source is treated like a plain one. Both the structural parse and the\text{...}fallback read that one table, so there was nothing else to change.How did you verify your code works?
packages/latex/src/parser.test.tsgains two cases:a\ bin strict mode must parse to a space node between the two symbols, and the formula from the issue must not throw; the second case covers a backslash before a newline, a tab and a CRLF.This branch merges into
dev(367d24b70) without conflicts. On that merged tree,bun testinpackages/latexis green (125 tests across 6 files) andbun run typecheck:tscis clean. With thesymbols.tshunk reverted the first new test fails withUnsupported command \.Screenshots / recordings
No rendering code changed, so I did not record the TUI. The visible difference is that a block which used to fall back to raw LaTeX now renders; the before state is in the issue.
Checklist