-
Notifications
You must be signed in to change notification settings - Fork 925
fix(markdown): escape pipes in code spans inside table cells #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
codeAnqiang-ma
wants to merge
2
commits into
firecrawl:main
Choose a base branch
from
codeAnqiang-ma:fix/code-span-table-pipe-escape
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: When code content already has an odd number of backslashes before
|, this replacement makes the run even and the generated GFM row can still split at that pipe. Add a backslash only when the existing run is even, and cover code such asa \| bwith a regression test.Prompt for AI agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the careful look — I checked this against the GFM reference implementation and against GitHub itself, and the row cannot split there: GFM's cell scanning is not parity-based. The cell scanner (
ext_scanners.reL32–L35,table_cell = (escaped_char|[^|\r\n])+) matches greedily, so a pipe preceded by any backslash never ends a cell, andunescape_pipes()then strips exactly one backslash before each|. So for code texta \| b, the emitted`a \\| b`renders back as<code>a \| b</code>— an exact round-trip.Verified via GitHub's own renderer (
gh api /markdown):Both rows keep two columns, and the cells come back as
<code>one | two</code>and<code>one \| two</code>. pulldown-cmark matches GitHub exactly; comrak also keeps every row intact.The parity variant would instead leave
a \| bunescaped, and GFM unescapes\|→|inside code spans too (spec §4.10, example 200), so the backslash would be silently dropped — on every renderer I tested (GitHub, comrak, pulldown-cmark, marked, micromark).For completeness: marked and micromark do split on
`one \\| two`— their cell splitters count backslash parity and deviate from cmark-gfm here. Under those parsers a backslash directly before a pipe inside a code span is unrepresentable either way (escaped, the row splits; unescaped, the backslash is lost), so I kept the encoding that GitHub and the reference implementation render exactly.Added a regression test covering
a \| bin d6fdf04.