diff --git a/docling/backend/asciidoc_backend.py b/docling/backend/asciidoc_backend.py index c6a0d18938..644e48f46e 100644 --- a/docling/backend/asciidoc_backend.py +++ b/docling/backend/asciidoc_backend.py @@ -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 diff --git a/tests/test_backend_asciidoc.py b/tests/test_backend_asciidoc.py index 4decdff74b..aedcfb9b17 100644 --- a/tests/test_backend_asciidoc.py +++ b/tests/test_backend_asciidoc.py @@ -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"))