Files
docling-core/test/data/doc/cdata_always.gt.dclg.xml
Panos Vagenas 3704874312 feat(doclang): add support for .dclx archive, <description>, <summary> (#658)
* feat(doclang): add .dclx archive save and load support

- Add `DoclingDocument.save_as_doclang_archive()` and `load_from_doclang_archive()` for DocLang OPC archives (`.dclx`)
- Store markup in `document.xml` with page rasters under `pages/` and picture assets under `assets/`
- Resolve relative `<src uri="..."/>` paths when loading from an extracted archive
- Bump DocLang serialization to version `0.7` and update namespace/version golden fixtures
- Restore picture images from archive-relative URIs via `DocLangDocDeserializer` (`media_root`)
- Add safe zip extraction and archive path helpers in `docling_core.types.doc.utils`
- Promote `doclang` to a runtime dependency (`>=0.7,<0.8`) on PyPI 0.7.0
- Remove `doclang` from dev dependency group and refresh `uv.lock`
- Add `test/test_doclang_archive.py` with save, load, and roundtrip coverage
- Add two-page archive fixtures under `test/data/doc/doclang_archive/`

Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>

* feat(doclang): add support for `<description>` and `<summary>`

Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>

---------

Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
2026-06-25 18:06:10 +02:00

222 lines
5.8 KiB
XML
Vendored

<doclang>
<list>
<ldiv>
<marker><![CDATA[■]]></marker>
</ldiv>
<![CDATA[item of leading list]]>
</list>
<heading><![CDATA[Title of the Document]]></heading>
<text>
<content><![CDATA[Author 1
Affiliation 1]]></content>
</text>
<text>
<content><![CDATA[Author 2
Affiliation 2]]></content>
</text>
<heading level="2"><![CDATA[1. Introduction]]></heading>
<text><![CDATA[This paper introduces the biggest invention ever made. ...]]></text>
<list>
<ldiv>
<marker><![CDATA[■]]></marker>
</ldiv>
<![CDATA[list item 1]]>
<ldiv>
<marker><![CDATA[■]]></marker>
</ldiv>
<![CDATA[list item 2]]>
<ldiv>
<marker><![CDATA[■]]></marker>
</ldiv>
<text><![CDATA[list item 3]]></text>
<list class="ordered">
<ldiv/>
<![CDATA[list item 3.a]]>
<ldiv/>
<![CDATA[list item 3.b]]>
<ldiv/>
<text><![CDATA[list item 3.c]]></text>
<list class="ordered">
<ldiv/>
<![CDATA[list item 3.c.i]]>
</list>
</list>
<ldiv>
<marker><![CDATA[■]]></marker>
</ldiv>
<![CDATA[list item 4]]>
</list>
<table>
<caption><![CDATA[This is the caption of table 1.]]></caption>
<fcel/>
<![CDATA[Product]]> <fcel/>
<![CDATA[Years]]> <lcel/>
<nl/>
<ucel/>
<fcel/>
<![CDATA[2016]]> <fcel/>
<![CDATA[2017]]> <nl/>
<fcel/>
<![CDATA[Apple]]> <fcel/>
<![CDATA[49823]]> <fcel/>
<![CDATA[695944]]> <nl/>
</table>
<picture>
<caption><![CDATA[This is the caption of figure 1.]]></caption>
</picture>
<picture>
<caption><![CDATA[This is the caption of figure 2.]]></caption>
<src uri="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAdElEQVRoBdXBAQEAAABAIP6ftkPJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMzJnMwFULoAQbykEYoAAAAASUVORK5CYII="/>
</picture>
<list>
<ldiv>
<marker><![CDATA[■]]></marker>
</ldiv>
<![CDATA[item 1 of list]]>
</list>
<list>
<ldiv>
<marker><![CDATA[*]]></marker>
</ldiv>
<![CDATA[item 1 of list after empty list]]>
<ldiv/>
<![CDATA[item 2 of list after empty list]]>
</list>
<list>
<ldiv>
<marker><![CDATA[■]]></marker>
</ldiv>
<![CDATA[item 1 of neighboring list]]>
<ldiv>
<marker><![CDATA[■]]></marker>
</ldiv>
<text><![CDATA[item 2 of neighboring list]]></text>
<list>
<ldiv>
<marker><![CDATA[□]]></marker>
</ldiv>
<![CDATA[item 1 of sub list]]>
<ldiv>
<marker><![CDATA[□]]></marker>
</ldiv>
<![CDATA[Here a code snippet:]]>
<code>
<label value="Python"/>
<![CDATA[print("Hello world")]]> </code>
<![CDATA[(to be displayed inline)]]>
<ldiv>
<marker><![CDATA[□]]></marker>
</ldiv>
<![CDATA[Here a formula:]]>
<formula><![CDATA[E=mc^2]]></formula>
<![CDATA[(to be displayed inline)]]>
</list>
</list>
<text><![CDATA[Here a code block:]]></text>
<code>
<label value="Python"/>
<![CDATA[print("Hello world")]]> </code>
<text><![CDATA[Here a formula block:]]></text>
<formula><![CDATA[E=mc^2]]></formula>
<text>
<![CDATA[Some formatting chops:]]>
<bold><![CDATA[bold]]></bold>
<italic><![CDATA[italic]]></italic>
<underline><![CDATA[underline]]></underline>
<strikethrough><![CDATA[strikethrough]]></strikethrough>
<subscript><![CDATA[subscript]]></subscript>
<superscript><![CDATA[superscript]]></superscript>
<![CDATA[hyperlink]]>
<![CDATA[&]]>
<strikethrough>
<underline>
<italic>
<bold><![CDATA[everything at the same time.]]></bold>
</italic>
</underline>
</strikethrough>
</text>
<list class="ordered">
<ldiv>
<marker><![CDATA[(i)]]></marker>
</ldiv>
<![CDATA[Item 1 in A]]>
<ldiv>
<marker><![CDATA[(ii)]]></marker>
</ldiv>
<![CDATA[Item 2 in A]]>
<ldiv>
<marker><![CDATA[(iii)]]></marker>
</ldiv>
<text><![CDATA[Item 3 in A]]></text>
<list class="ordered">
<ldiv/>
<![CDATA[Item 1 in B]]>
<ldiv>
<marker><![CDATA[42.]]></marker>
</ldiv>
<text><![CDATA[Item 2 in B]]></text>
<list class="ordered">
<ldiv/>
<![CDATA[Item 1 in C]]>
<ldiv/>
<![CDATA[Item 2 in C]]>
</list>
<ldiv/>
<![CDATA[Item 3 in B]]>
</list>
<ldiv>
<marker><![CDATA[(iv)]]></marker>
</ldiv>
<![CDATA[Item 4 in A]]>
</list>
<list>
<ldiv/>
<![CDATA[List item without parent list group]]>
</list>
<text><![CDATA[The end.]]></text>
<text><![CDATA[Simple text]]></text>
<text>
<content><![CDATA[ 4 leading spaces, 1 trailing ]]></content>
</text>
<text><![CDATA[Some 'single' quotes]]></text>
<text><![CDATA[Some "double" quotes]]></text>
<text>
<summary><![CDATA[Summary with <tags> & ampersands]]></summary>
<![CDATA[An ampersand: &]]> </text>
<picture>
<description><![CDATA[Description content]]></description>
</picture>
<code><![CDATA[0 == 0]]></code>
<code>
<content><![CDATA[ 1 leading space, 4 trailing ]]></content>
</code>
<code><![CDATA[0 < 1]]></code>
<code>
<label value="Python"/>
<![CDATA[42 == 42]]> </code>
<code>
<label value="Python"/>
<![CDATA[42 < 1337]]> </code>
<table>
<fcel/>
<![CDATA[Foo]]> <fcel/>
<![CDATA[Bar]]> <nl/>
<fcel/>
<![CDATA[Header & Title]]> <fcel/>
<![CDATA[Value > 100]]> <nl/>
<fcel/>
<![CDATA[<script>]]> <fcel/>
<![CDATA[A & B]]> <nl/>
<fcel/>
<![CDATA[Only]]> <fcel/>
<![CDATA[<second>]]> <nl/>
</table>
<text><![CDATA[0 < 1]]></text>
<text>
<italic>
<bold><![CDATA[0 < 42]]></bold>
</italic>
</text>
</doclang>