Doclingdocling 2.127.0 · Python 3.10+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
26 small wins to finish your pathNext lesson

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.

Example
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

Example
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

Example
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.

DocTags is also an input. Docling's vision pipeline runs a model over a page image and the model emits DocTags, which Docling parses back into the document object you have been using. Lesson 26 says what that pipeline needs.
Try it yourself
  • Export couriers.html as 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.html and see which tag it gets.

You understood something today that you didn't yesterday.