Skip to content

fix: keep label literals in code arguments when escaping deleted content - #65

Open
andrader wants to merge 1 commit into
sou1118:mainfrom
andrader:fix/escape-code-labels
Open

andrader wants to merge 1 commit into
sou1118:mainfrom
andrader:fix/escape-code-labels

Conversation

@andrader

@andrader andrader commented Nov 7, 2026

Copy link
Copy Markdown

Deleted content no longer escapes a label literal that is a code argument. Before, only the first argument of #ref(...) was left alone, so other calls produced output that does not parse:

#diff-deleted[As shown by #cite(\<key>, form: "prose"), it works.]   // before: `\` is not valid in code
#diff-deleted[As shown by #cite(<key>, form: "prose"), it works.]    // after

code_label_offsets parses the fragment with typst_syntax and collects the Label nodes whose parent is not Markup. Typst parses text <lbl> and #cite(<key>) as the same node kind, and only the parent tells them apart. This covers any argument position, named arguments, nested calls and #let bindings. It replaces the is_ref_label_arg text check, and #ref is now one case of the general rule. Labels in markup, including those inside a content argument (#link(<sec>)[see <lbl>]), and @refs are still escaped.

Tests: two unit tests (code labels at any position left alone; markup labels, @ref and a < b still escaped) and three integration tests (#cite, #link and the markup-label case), each checking the exact output and that it parses. cargo fmt --check, cargo clippy -- -D warnings, cargo test and both compile-test fixtures pass.

Fixes #63

…ent (sou1118#63)

escape_content escaped every `<` in deleted content except the first
argument of `#ref(...)`, so `#cite(<key>)` and `#link(<sec>)[..]` became
`\<key>` inside the call, which does not parse.

A label is now left alone whenever the Typst parser places it outside
markup (an argument at any position, a named argument, a nested call, a
binding). Labels in markup, including those inside a content block, and
`@ref`s are still escaped. This replaces the `#ref` text heuristic.
Copilot AI balanced review requested due to automatic review settings November 7, 2026 22:48
@coderabbitai

coderabbitai Bot commented Nov 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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 39 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8b7f1ac7-521f-4536-ba03-8628115aa01e
Commits

Reviewing files that changed from the base of the PR and between d7d062b and 92e10f5.

Files selected for processing: 2

  • src/render.rs
  • tests/integration.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deleted content escapes label arguments of #cite and #link as \<label>, which does not parse

2 participants