ODT comments are spliced into the body text
Author: devYRPauliCreated Sep 29, 2026Updated Sep 29, 2026
Labelsbug
Bug
An ODT comment (office:annotation) sits inline in the paragraph, heading, list item or table cell it annotates. OdtDocumentBackend reads the author, date and text of the comment as part of that element. The comment lands in the middle of the document text, and no comment reaches the NOTES layer.
LibreOffice Writer saves every comment in this shape. The DOCX, XLSX and PPTX backends put comments in a COMMENT_SECTION group in the NOTES layer.
Steps to reproduce
from odfdo import Document, Element
from docling.document_converter import DocumentConverter
def ann(text):
return (
"<office:annotation><dc:creator>Ann Reviewer</dc:creator>"
"<dc:date>2024-01-15T10:00:00</dc:date>"
"<meta:creator-initials>AR</meta:creator-initials>"
f"<text:p>{text}</text:p></office:annotation>"
)
cell = "<table:table-cell office:value-type='string'><text:p>{}</text:p></table:table-cell>"
odt = Document("text")
odt.body.clear()
for xml in [
f"<text:h text:outline-level='1'>Budget{ann('Rename this heading')}</text:h>",
f"<text:p>The total is {ann('Source?')}42 EUR.</text:p>",
f"<text:list><text:list-item><text:p>First item{ann('Too vague')}</text:p></text:list-item></text:list>",
"<table:table table:name='T'><table:table-row>"
+ cell.format("Key")
+ cell.format(f"Val{ann('Cell remark')}")
+ "</table:table-row></table:table>",
]:
odt.body.append(Element.from_tag(xml))
odt.save("comment.odt")
doc = DocumentConverter().convert("comment.odt").document
print(doc.export_to_markdown())
print([t.text for t in doc.texts if t.content_layer == "notes"])Output on main (98d78ef8):
## BudgetAnn Reviewer2024-01-15T10:00:00ARRename this heading
The total is Ann Reviewer2024-01-15T10:00:00ARSource?42 EUR.
- First itemAnn Reviewer2024-01-15T10:00:00ARToo vague
| Key | ValCell remark Ann Reviewer 2024-01-15 10:00:00 |
|-------|---------------------------------------------------|
[]Expected: the markdown has no comment text, and each comment is in a COMMENT_SECTION group in the NOTES layer.
Docling version
Docling version: 2.130.0
Docling Core version: 2.98.0
Docling IBM Models version: 4.0.2
Docling Parse version: 7.20.0
Python: cpython-313 (3.13.14)
Platform: macOS-27.0-arm64-arm-64bit-Mach-OPython version
Python 3.13.14
Source: docling-project/docling