iOfficeAI / iOfficeAI/OfficeCLI

# Tracked find-replace cannot operate on text inside w:hyperlink (revision-mode deletion of link text impossible)

Open
#279 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
30.7k
Forks
2.1k
Avg merge
9d 8h
Merged PRs (30d)
5

Description

## Describe the limitation

`set / --find X --replace Y --prop revision.author=...` fails when the matched text spans a `w:hyperlink` boundary:

```
Error: find/replace+revision cannot span a hyperlink boundary (match at offset 59, length 3)
```

## Use case

In tracked-changes workflows (e.g. AI-applied manuscript revisions), text inside hyperlinks — like the "原文" (original) link text in reference lists, or URL labels — often needs revision-mode deletion. Currently impossible via the CLI; the only workaround is editing document.xml directly to wrap the hyperlink element in `w:del`.

## Suggested behavior

- When the full match is contained within a single hyperlink whose text lives in one run, wrap the whole hyperlink in `w:del` and emit the replacement as `w:ins` (mirroring how plain runs are handled).
- Keep failing with a clearer message for partial-coverage matches.

## Repro (v1.0.143)

Document with a source-entry paragraph ending in `…。` + hyperlink "原文":

```
officecli set refs.docx / --find " 原文" --replace "" --prop revision.author=A
→ Error: find/replace+revision cannot span a hyperlink boundary (match at offset 59, length 3)
```

Contributor guide

Open the contributing guide

Research direction

Start with the `officecli set refs.docx / --find ... --replace ... --prop revision.author=A` reproduction and trace the find/replace+revision path that emits the hyperlink-boundary error. Compare the existing plain-run revision behavior with the document.xml workaround described here. Done means a match fully contained in one hyperlink is deleted and replaced in tracked-change markup, while partial-coverage matches still fail with a clearer message.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.