fix: handle escaped pipe characters in markdown table cells#2475
Closed
Br1an67 wants to merge 1 commit intoQwenLM:mainfrom
Closed
fix: handle escaped pipe characters in markdown table cells#2475Br1an67 wants to merge 1 commit intoQwenLM:mainfrom
Br1an67 wants to merge 1 commit intoQwenLM:mainfrom
Conversation
Table cells containing literal pipe characters (e.g. `A|B`) were
incorrectly split into separate columns because the parser used a naive
`.split('|')`. This replaces it with a regex split on unescaped pipes
LLMs can now output `A\|B` in table cells and it will render correctly
as `A|B` in a single column.
Fixes QwenLM#2461
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
Closing in favor of #2503 which has the cleaner implementation with a dedicated |
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
Fixes table rendering when cells contain literal
|characters (e.g.A|B). Previously, the naive.split("|")incorrectly broke such content into separate columns. Now uses a regex split on unescaped pipes with\|→|unescaping.Dive Deeper
Root cause:
MarkdownDisplay.tsxlines 114 and 130 used.split("|")to parse table rows, which cannot distinguish between structural column delimiters and literal pipe characters in cell content.Fix: Added a
splitTableRow()helper that:(?<!\\)\|\|→|in the resulting cell textLLMs can output
A\|Bin table cells and it renders correctly asA|Bin a single column. This follows the standard Markdown table escaping convention.Reviewer Test Plan
|(e.g. union types likestring|number)\|in tablesTesting Matrix
Linked issues / bugs
Fixes #2461