From 92e10f5c73cc9a4d78e4a3e40c7ae5ec410b0f19 Mon Sep 17 00:00:00 2001 From: Rubens Andrade <38709237+andrader@users.noreply.github.com> Date: Sat, 7 Nov 2026 19:43:29 -0300 Subject: [PATCH] fix: keep label literals in code arguments when escaping deleted content (#63) escape_content escaped every `<` in deleted content except the first argument of `#ref(...)`, so `#cite()` and `#link()[..]` became `\` 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. --- src/render.rs | 83 +++++++++++++++++++++++++++++++++++++------- tests/integration.rs | 35 +++++++++++++++++++ 2 files changed, 105 insertions(+), 13 deletions(-) diff --git a/src/render.rs b/src/render.rs index 37a775a..c42487a 100644 --- a/src/render.rs +++ b/src/render.rs @@ -244,11 +244,18 @@ fn write_enum_prefix(number: Option, out: &mut String) { /// - When `escape_refs` is true, `@` is escaped as `\@` and `<` is escaped /// as `\<` to suppress reference resolution and label creation (used for /// deleted content where the referenced label may no longer exist or would -/// create duplicates). Label literals inside `#ref(