Skip to content
Merged
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
10 changes: 7 additions & 3 deletions docling/backend/asciidoc_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,14 @@ def _parse_picture(line):

# Extract optional attributes (alt text, width, height, alignment)
if attributes:
picture_info["alt"] = attributes[0].strip() if attributes[0] else ""
alt_parts = [attributes[0].strip()] if attributes[0] else [""]
for attr in attributes[1:]:
key, value = attr.split("=")
picture_info[key.strip()] = value.strip()
if "=" in attr:
key, value = attr.split("=", 1)
picture_info[key.strip()] = value.strip()
else:
alt_parts.append(attr.strip())
picture_info["alt"] = ", ".join(alt_parts)

return picture_info

Expand Down
11 changes: 11 additions & 0 deletions tests/test_backend_asciidoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ def test_parse_picture():
assert "height" not in res
assert res.get("uri", "") == "renamed-bookmark.png"

line = "image::images/screenshot.png[A screenshot showing a dialog box, containing text fields, buttons, and validation errors, width=604, height=422]"
res = AsciiDocBackend._parse_picture(line)
assert res
assert res.get("width", 0) == "604"
assert res.get("height", 0) == "422"
assert res.get("uri", "") == "images/screenshot.png"
assert (
res.get("alt", "")
== "A screenshot showing a dialog box, containing text fields, buttons, and validation errors"
)


def test_asciidocs_examples():
fnames = sorted(glob.glob("./tests/data/asciidoc/*.asciidoc"))
Expand Down