fix(tui): protect pipe characters inside inline code in markdown tables#5812
Closed
aliou wants to merge 1 commit into
Closed
fix(tui): protect pipe characters inside inline code in markdown tables#5812aliou wants to merge 1 commit into
aliou wants to merge 1 commit into
Conversation
f94364f to
3878f6f
Compare
Member
|
I just upgraded marked instead which appears to solve this problem too. |
Contributor
Author
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.

Hello!
Noticed this bug: when rendering a table that has in one of its cell a
|inside of backsticks, marked will use as a column delimitor and split on it, discarding the content after it.To handle it, this uses the existing custom tokenizer and overrides how table should be rendered, customizing the column split.
Session: https://pi.dev/session/#fbe66e539f15604016fa459a55a89ed7
One caveat: the verison of marked is a couple of majors late and in the latest version, the API around tokenizer changes for the existing
deloverrides; the rest of the API is the same (see other tree in the session for the check).Let me know if you need/want more other changes!
Before
After
Summary by Kimi K2.7 Code:
What changed
packages/tui/src/components/markdown.ts: ReplacedStrictStrikethroughTokenizerwithMarkdownTokenizer. It keeps the existing strict strikethroughdeloverride and adds atableoverride.tablemethod usessplitCellsRespectingCodeSpans, which splits table rows on|while treating everything inside backtick code spans as literal text. It still honors\|as an escaped pipe.Why
markedtokenizes table rows before resolving inline code spans. A cell like`TFile | null`was therefore split at the pipe, and becausemarkedtruncates rows to the header column count, the trailing| nullwas silently dropped.Verification
npm run checkpasses.node --test test/*.test.tsinpackages/tuipasses (682 tests), including the new regression test inpackages/tui/test/markdown.test.ts../test.shfrom root currently fails on unrelatedpackages/coding-agenttests (session-id-readonly.test.ts,footer-data-provider.test.ts), not on this change.