extract_fragments
Extract text from a .docx file as tagged fragments with unique IDs, enabling targeted changes and redlining.
Instructions
Extract text from a .docx file as tagged fragments.
Call this first to get fragment IDs, then use those IDs in ``apply_changes``.
Output format::
<f=1>**Title**</f=1>
<f=2>Body paragraph.</f=2>
<table=3 rows=2 cols=3>
<cell=3.1.1>Header</cell=3.1.1>
<cell=3.1.2 span="2">Merged cell</cell=3.1.2>
</table=3>
Fragment IDs:
- Body: ``"1"``, ``"2"``, ...
- Headers: ``"header_1.1"``, ``"header_1.2"``, ...
- Footers: ``"footer_1.1"``, ``"footer_2.1"``, ...
- Table cells: ``"table_id.row.col"`` (e.g., ``"3.1.2"``)
Formatting: ``**bold**``, ``_italic_``, ``__underline__``. ``
`` for paragraph breaks.
Limitations:
- Images, nested tables, VML text boxes are skipped.
- Pre-existing tracked changes are hard-rejected.
Args:
document_path: Absolute path to the .docx file.
Returns:
Tagged text string with fragment and table markup.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| document_path | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |