mirror of
https://github.com/DS4SD/docling.git
synced 2025-12-08 20:58:11 +00:00
fix(asciidoc): set default size when missing in image directive (#1769)
The AsciiDoc backend should not create an ImageRef with Size equal to None, instead use default size values. Refactor static methods as such and add the staticmethod decorator. Extend the regression test for this fix. Signed-off-by: Cesar Berrospi Ramis <75900930+ceberam@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
7d3302cb48
commit
b886e4df31
@@ -2,7 +2,11 @@ import glob
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from docling.backend.asciidoc_backend import AsciiDocBackend
|
||||
from docling.backend.asciidoc_backend import (
|
||||
DEFAULT_IMAGE_HEIGHT,
|
||||
DEFAULT_IMAGE_WIDTH,
|
||||
AsciiDocBackend,
|
||||
)
|
||||
from docling.datamodel.base_models import InputFormat
|
||||
from docling.datamodel.document import InputDocument
|
||||
|
||||
@@ -18,6 +22,24 @@ def _get_backend(fname):
|
||||
return doc_backend
|
||||
|
||||
|
||||
def test_parse_picture():
|
||||
line = (
|
||||
"image::images/example1.png[Example Image, width=200, height=150, align=center]"
|
||||
)
|
||||
res = AsciiDocBackend._parse_picture(line)
|
||||
assert res
|
||||
assert res.get("width", 0) == "200"
|
||||
assert res.get("height", 0) == "150"
|
||||
assert res.get("uri", "") == "images/example1.png"
|
||||
|
||||
line = "image::renamed-bookmark.png[Renamed bookmark]"
|
||||
res = AsciiDocBackend._parse_picture(line)
|
||||
assert res
|
||||
assert "width" not in res
|
||||
assert "height" not in res
|
||||
assert res.get("uri", "") == "renamed-bookmark.png"
|
||||
|
||||
|
||||
def test_asciidocs_examples():
|
||||
fnames = sorted(glob.glob("./tests/data/asciidoc/*.asciidoc"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user