Skip to content
Closed
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
3 changes: 3 additions & 0 deletions docling/backend/opendocument_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ def _odf_text_runs(
if text_recursive.startswith(text):
text = text_recursive
return [_OdfTextRun(text=text, formatting=formatting)]
if tag == "text:s":
text_recursive = getattr(element, "text_recursive", " ")
return [_OdfTextRun(text=text_recursive, formatting=formatting)]
if tag == "text:tab":
return [_OdfTextRun(text="\t", formatting=formatting)]

Expand Down
19 changes: 19 additions & 0 deletions tests/test_backend_opendocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
List as OdfList,
ListItem,
Paragraph,
Spacer,
Span,
Style,
Table,
Expand Down Expand Up @@ -436,6 +437,24 @@ def test_odt_text_document_text_formatting():
assert "~~The Extremes of Good and Evil~~" in markdown


def test_odt_text_after_space_in_span(tmp_path: Path):
path = tmp_path / "span_tail.odt"
doc = OdfDocument("text")
body = doc.body
body.clear()

space = Spacer()
space.tail = "connective prose here"
span = Span()
span.append(space)
body.append(Paragraph(span))
doc.save(str(path))

res = DocumentConverter(allowed_formats=[InputFormat.ODT]).convert(path)

assert res.document.export_to_markdown() == "connective prose here"


def test_odt_text_document_script_formatting():
path = Path("tests/data/odf/sources/text_document_01.odt")

Expand Down
Loading