fix: handle escaped pipe characters in markdown table cells#2503
Open
Br1an67 wants to merge 1 commit intoQwenLM:mainfrom
Open
fix: handle escaped pipe characters in markdown table cells#2503Br1an67 wants to merge 1 commit intoQwenLM:mainfrom
Br1an67 wants to merge 1 commit intoQwenLM:mainfrom
Conversation
Table cells containing literal `|` characters (e.g. `A|B`) were
incorrectly split across columns because the parser used a naive
`split('|')`. This adds a `splitTableCells` helper that splits on
unescaped `|` only (using a negative lookbehind) and then un-escapes
`\\\|` back to `|` in each cell.
Closes QwenLM#2461
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.
TLDR
Table cells containing literal
|characters (e.g.A|B) were incorrectly split across columns. This fixes the markdown table parser to respect escaped\|sequences.Dive Deeper
The
MarkdownDisplay.tsxcomponent parses markdown tables by splitting rows on|usingsplit("|"). This treats every|as a column delimiter, even when the character is part of the cell content (e.g. type unionsA|B, regex patterns[a|b]).Root cause: Lines 114 and 130 of
MarkdownDisplay.tsxused naivesplit("|").Fix: Added a
splitTableCells()helper that:|only, using a negative lookbehind regex:/(?<!\\)\|/\|back to|in each cell via.replace(/\\\|/g, "|")This follows standard markdown table escaping conventions (e.g. GitHub Flavored Markdown).
Testing Matrix
A\|Brenders asA|Bin a single cell\|is not left as literal escaped textCloses #2461