mirror of
https://github.com/docling-project/docling-core.git
synced 2026-11-18 20:27:00 +00:00
DocLangDocSerializer raised "level must be in [1, 6]" for any SectionHeaderItem with level 6. That is reachable in normal use, not a synthetic edge case: SectionHeaderItem.level accepts up to 100, and docling's heading-hierarchy inference emits level-6 headings by default, so a PDF with nested procedure lists crashes the serializer. The +1 shift (level 1 is reserved for TitleItem) pushed level 6 to 7, past the heading token's allowed range, with nothing clamping it back. html.py already clamps the identical item.level + 1 computation with min(..., 6); this applies the same treatment, which is the smallest fix and keeps the two serializers consistent. Fixes #685 Signed-off-by: Max Hsu <maxmilian@gmail.com>