replace_text
Replace or delete text in a specific paragraph using its ID, preserving formatting across DOCX, ODT, and Google Docs. Tracks changes for review.
Instructions
Replace text in a paragraph by provider paragraph id, preserving formatting where supported. Supports DOCX, ODT, and Google Docs. To delete an ordinary DOCX body paragraph, pass its complete visible text as old_string and an empty new_string; a clean save removes the paragraph and a tracked save keeps the deletion for review. Do not use this shortcut for paragraphs that carry section properties, are structurally required by a table cell, or own bookmark/comment anchors without inspecting the structure first. Surface: revisionable — DOCX edits emit native OOXML tracked changes (w:ins/w:del/w:rPrChange).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | No | Path to the DOCX or ODT file. | |
| new_string | Yes | ||
| old_string | Yes | ||
| instruction | Yes | ||
| google_doc_id | No | Google Doc ID or URL (alternative to file_path). Extract from URL: docs.google.com/document/d/{ID}/edit | |
| normalize_first | No | Merge format-identical adjacent runs before searching. Useful when text is fragmented across runs. | |
| target_paragraph_id | Yes | Paragraph anchor. Accepts a safe-docx `_bk_*` id, or (DOCX only) any other bookmark name — e.g. a host application's own stable paragraph bookmark — whose w:id-paired range covers exactly this one paragraph. Exact name match; a point bookmark or a multi-paragraph range is refused. |