DocTags, the format the models speak
The last export is the one Docling uses to talk to itself, and it is the only one that keeps every label.
Markdown says ## and means heading, level two. Plain text says nothing at all. DocTags names each piece with the label it carries, which makes it the format Docling's own vision models are trained to produce and read.
print(document.export_to_doctags())Each piece is wrapped in a tag named after its label, and the list from lesson 5 is an unordered_list holding its two items. Reading this next to the iterate_items output from lesson 4 shows they are the same information.
Tables become a grid language
print(document.export_to_doctags())The table came out as otsl, a compact way of writing a grid: ched for a column header cell, fcel for an ordinary one and nl for the end of a row. Unlike Markdown it can express a cell that covers more than one row or column: a covered position gets ucel or lcel instead of a value, so the span survives. Export couriers.html this way and you will find one.
It costs more characters
print(len(document.export_to_doctags()), "characters as DocTags")
print(len(document.export_to_markdown()), "as Markdown")Roughly twice the size for this file. That is the trade: DocTags keeps the structure explicit and pays for it in tokens. Use Markdown when a model only needs to read the words, and DocTags when something downstream needs to know what each piece was.
- Export
couriers.htmlas DocTags and find the cell that covers two rows. - Compare the DocTags and Markdown lengths for
orders.csv. - Add a caption to the table in
refunds.htmland see which tag it gets.
You understood something today that you didn't yesterday.