Repository navigation
fix(id/web): newline-destination protection skips literal code contexts (#1707) - #3746
Conversation
… inline code spans, indented code blocks, fence char/length respected, whitespace-only blank lines break the destination scan (#1707)
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 42 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2e6c9f277
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| }; | ||
| match (fence, fence_run) { | ||
| (None, Some(open)) => fence = Some(open), | ||
| (Some((ch, n)), Some((cch, cn))) if cch == ch && cn >= n => fence = None, |
There was a problem hiding this comment.
Keep closing fence lines out of inline span tracking
After a backtick fence closes, fence becomes None before literal_line is computed, so the closing backticks reach the inline-code tracker and open a new span. For example, "```\nexample\n```\n\n[y](<c\nd>)\n" now returns no protection token, leaving the subsequent newline-containing link unparseable by comrak and losing its href on reopen. The newly added mixed control also exercises this failure. Treat the closing fence line itself as literal rather than feeding its delimiter into span tracking.
Useful? React with 👍 / 👎.
| match span { | ||
| None => span = Some(n), | ||
| Some(open) if n == open => span = None, |
There was a problem hiding this comment.
Only open spans for valid, unescaped backtick delimiters
When an earlier paragraph contains an unmatched or escaped backtick, this unconditional assignment treats subsequent content as code indefinitely, including across paragraph boundaries. For example, "plain unmatched\n\ny\n"` now returns no protection token, whereas the parent commit protects the link. Consequently, an ordinary literal backtick can cause later newline-containing links to lose their link marks and hrefs on reopen. Only matched, unescaped delimiters within the relevant inline block should suppress destination protection.
Useful? React with 👍 / 👎.
| // after a blank line (or at the start, or continuing an | ||
| // indented block); a 4+ indented line inside a paragraph | ||
| // is a lazy continuation, not code. | ||
| in_indented = indent >= 4 && fence.is_none() && (prev_line_blank || prev_line_indented); |
There was a problem hiding this comment.
Account for list indentation before classifying code blocks
For a continuation paragraph inside a list item, four leading spaces do not necessarily indicate an indented code block: indentation must first be measured relative to the list container. For example, "- item\n\n [x](<a\n b>)\n" is now skipped as code even though the link belongs to a normal list-item paragraph. The parent commit protects its destination, but this version leaves it unprotected, so reopening loses the newline-containing link. Classify indentation relative to enclosing containers rather than using the absolute four-space threshold.
Useful? React with 👍 / 👎.
Fixes #1707 (queue task 4788).
protect_newline_destinations(pkgs/id/src/web/markdown.rs) now treats all literal contexts as literal, not just plain fenced blocks:```line inside a````block no longer ends it early.>scan now breaks on\n[ \t\r]*\n, exactly like\n\n, so a paragraph-broken destination is no longer protected into an invented link.Untouched per the packet scope: the token scheme and the save-side
substitute_spaced_destinations.Tests: new
test_newline_destination_protection_skips_literal_contextspins all four cases plus controls (plain fence unchanged; genuine inline destination still protected; a genuine destination after a fenced block still protected; end-to-end check that no converted doc contains the token and the paragraph-broken shape gains no link mark). Existing #1423 round-trip tests must stay green.Verification status: targeted
cargo test --lib --features web web::markdownis running on the laptop (cold target dir under heavy fleet load); CI on this PR is the deciding run — this PR is parked in the queue awaiting both.Need help on this PR? Tag
@codesmith-botwith what you need.