Skip to content

fix(rtf): omit text of deleted revisions - #216

Open
Aschenbath wants to merge 4 commits into
firecrawl:mainfrom
Aschenbath:rtf-omit-deleted
Open

Aschenbath wants to merge 4 commits into
firecrawl:mainfrom
Aschenbath:rtf-omit-deleted

Conversation

@Aschenbath

@Aschenbath Aschenbath commented Oct 31, 2026 •

Copy link
Copy Markdown

Fixes the RTF part of #202. The DOC part is #174; DOCX is untouched.

Problem

RTF tracked deletions (\deleted) were printed as live text. The parties agreed {\deleted OLDTERM }{\revised NEWTERM }terms. rendered as The parties agreed OLDTERM NEWTERM terms., so both the old and the new wording appeared.

Change

\deleted (and \deleted0) now sets a group-scoped deleted flag on the character state. Body text under that flag is left out. Pending bytes are flushed before the flag changes, so text on either side of the toggle keeps its own state. Insertions (\revised) stay as before.

Verification

  • New test deleted_revision_text_is_omitted covers both forms: a group-scoped deletion and an inline \deleted ... \deleted0. It fails on main and passes with the change.
  • cargo test: all suites pass.
  • rustfmt --check on the changed file: clean.

🤖 Generated with Claude Code


Summary by cubic

Fixes the RTF part of #202: tracked deletions (\deleted) were rendered as live text, so both old and new wording of a revised clause appeared. Deleted text — including line breaks, pictures, and equations — is now omitted from the output, and a deleted paragraph mark joins its paragraphs and drops its list marker instead of leaving a blank line; insertions (\revised) stay as before.

  • Adds regression tests covering group-scoped, inline, and element-containing \deleted forms, deleted paragraphs, and code-block output.

Written for commit dccaf92. Summary will update on new commits.

View guided diff

A tracked deletion (\deleted) printed as live text, so the old and new
wording of a revised clause both appeared. Text inside a deletion is now
left out, the same way the DOC path does in firecrawl#174; insertions stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot 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.

1 issue found across 1 file

Confidence score: 3/5

  • Deleted RTF groups can still emit pictures and equations in src/formats/rtf/mod.rs, exposing content that should be omitted. Make the \pict and \mmath finishers respect the deleted flag.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/formats/rtf/mod.rs">

<violation number="1" location="src/formats/rtf/mod.rs:1162">
P2: The `deleted` gate covers only text. Pictures (`\\pict`) and equations (`\\mmath`) inside a `\\deleted` group are still emitted, because their finishers never check the flag. Record `deleted` when the `\\pict` or `\\mmath` destination opens, and skip emission in `finish_pict`/`finish_math` when it was set.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread src/formats/rtf/mod.rs Resolved
Comment thread src/formats/rtf/mod.rs
}
Capture::None => {
if !self.state.suppress {
if !self.state.suppress && !self.state.deleted {

@cubic-dev-ai cubic-dev-ai Bot Oct 31, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The deleted gate covers only text. Pictures (\\pict) and equations (\\mmath) inside a \\deleted group are still emitted, because their finishers never check the flag. Record deleted when the \\pict or \\mmath destination opens, and skip emission in finish_pict/finish_math when it was set.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/formats/rtf/mod.rs, line 1162:

<comment>The `deleted` gate covers only text. Pictures (`\\pict`) and equations (`\\mmath`) inside a `\\deleted` group are still emitted, because their finishers never check the flag. Record `deleted` when the `\\pict` or `\\mmath` destination opens, and skip emission in `finish_pict`/`finish_math` when it was set.</comment>

<file context>
@@ -1151,7 +1159,7 @@ impl<'a> Parser<'a> {
             }
             Capture::None => {
-                if !self.state.suppress {
+                if !self.state.suppress && !self.state.deleted {
                     self.inlines.push(Inline::Text { text, style: self.state.style });
                 }
</file context>
Fix with cubic

Comment thread src/formats/rtf/mod.rs Resolved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot 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.

1 existing issue remains and no new issues found across 1 file (changes from recent commits).

Confidence score: 3/5

  • In src/formats/rtf/mod.rs, finish_pict can emit images marked deleted in their own picture group because it checks the restored enclosing state. Capture the deletion state when the picture opens and use it when finalizing.

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved P0–P2 issue already reported by Cubic.

View guided diff | Re-trigger cubic

Comment thread src/formats/rtf/mod.rs Resolved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 1 file (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread src/formats/rtf/mod.rs Resolved
… list marker

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant