Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docling/backend/asciidoc_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def _parse(self, doc: DoclingDocument):

elif in_list and item["indent"] < indents[level]:
# print(item["indent"], " => ", indents[level])
while item["indent"] < indents[level]:
while level > 0 and item["indent"] < indents[level]:
# print(item["indent"], " => ", indents[level])
parents[level] = None
indents[level] = None
Expand Down
18 changes: 18 additions & 0 deletions tests/test_backend_asciidoc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import glob
from io import BytesIO
from pathlib import Path

from docling.backend.asciidoc_backend import (
Expand All @@ -24,6 +25,23 @@ def _get_backend(fname):
return doc_backend


def test_list_dedent_to_base_does_not_crash():
# A list that starts indented and then dedents back to the base level used
# to raise "TypeError: '<' not supported between instances of 'int' and
# 'NoneType'": the dedent loop walked past level 0, where the base indent is
# never set. It should keep both items instead.
src = b" * a\n* b\n"
in_doc = InputDocument(
path_or_stream=BytesIO(src),
format=InputFormat.ASCIIDOC,
backend=AsciiDocBackend,
filename="dedent.asciidoc",
)
doc = in_doc._backend.convert()

assert [item.text for item in doc.texts] == ["a", "b"]


def test_parse_picture():
line = (
"image::images/example1.png[Example Image, width=200, height=150, align=center]"
Expand Down
Loading