Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(odt): disable multiline_tables in ODT export reader (#8073) (#8088)

HPH Proton1e7ff8404f33
diff --git a/changelog.d/8073.bugfix.md b/changelog.d/8073.bugfix.md
new file mode 100644
index 0000000000..18bbfb3ab2
--- /dev/null
+++ b/changelog.d/8073.bugfix.md
@@ -0,0 +1 @@
+ODT export now disables Pandoc's `multiline_tables` extension so a horizontal rule (`---`) directly followed by text, with the next `---` line coming after a blank line, stays a rule instead of wrapping the intervening report section and headings into a single table cell or truncating leading characters when indented. A `---` line, lines of text and another `---` line with no blank line between them are still read as a simple table, and pipe tables are unaffected. Genuine Pandoc multiline-table syntax in a report is no longer read as a multiline table: body rows render as paragraphs, and a headed table's header lines may render as a one-column table.
diff --git a/src/local_deep_research/exporters/odt_exporter.py b/src/local_deep_research/exporters/odt_exporter.py
index bb16eb138e..f5f100f5f7 100644
--- a/src/local_deep_research/exporters/odt_exporter.py
+++ b/src/local_deep_research/exporters/odt_exporter.py
@@ -63,18 +63,32 @@ class ODTExporter(BaseExporter):
#: whose closing tag is on the same line stays open to the end of the
#: document. A ``---`` line directly followed by text opens a YAML
#: metadata block, which moves report text into document properties,
- #: or fails the export when that text is not YAML (#7821). With all of
- #: these off, report text reaches the document as text, consistent
- #: with the PDF export and the on-screen report view, which escape raw
- #: HTML. Ordinary markdown converts identically, and the title, author
- #: and date still come from the ``--metadata`` arguments. Pandoc
- #: rejects an extension name it does not know, so a future rename fails
- #: the export instead of quietly restoring passthrough; every name here
- #: exists in every pandoc that supports ``--sandbox`` (2.15+), which
- #: export requires.
+ #: or fails the export when that text is not YAML (#7821). With
+ #: ``yaml_metadata_block`` off, a ``---`` line directly followed by
+ #: text, with the next ``---`` rule after a blank line (the footer's
+ #: ``---`` rule, or ``topic_organization_strategy.py``'s
+ #: ``\\n---\\n**Total Sources Organized:**``), would be read by
+ #: ``multiline_tables`` as a one-column table wrapping the intervening
+ #: report section and headings into a single cell, and an indented
+ #: rule would cut the leading characters off every following line.
+ #: With ``multiline_tables`` off, that shape stays a horizontal rule.
+ #: A ``---`` line, lines of text and another ``---`` line with no
+ #: blank line between them are still a simple table, and pipe tables
+ #: are unaffected. Genuine Pandoc multiline-table syntax in a report
+ #: is no longer read as a multiline table: body rows render as
+ #: paragraphs, and a headed table's header lines may render as a
+ #: one-column table. With all
+ #: of these off, report text reaches the document as text, consistent
+ #: with the PDF export and the on-screen report view, which escape
+ #: raw HTML. Ordinary markdown converts identically, and the title,
+ #: author and date still come from the ``--metadata`` arguments.
+ #: Pandoc rejects an extension name it does not know, so a future
+ #: rename fails the export instead of quietly restoring passthrough;
+ #: every name here exists in every pandoc that supports ``--sandbox``
+ #: (2.15+), which export requires.
READER_FORMAT = (
"markdown-raw_attribute-raw_html-raw_tex"
- "-native_divs-native_spans-yaml_metadata_block"
+ "-native_divs-native_spans-yaml_metadata_block-multiline_tables"
)
def __init__(
diff --git a/tests/exporters/test_odt_exporter.py b/tests/exporters/test_odt_exporter.py
index 765d7aaba3..55316623c4 100644
--- a/tests/exporters/test_odt_exporter.py
+++ b/tests/exporters/test_odt_exporter.py
@@ -759,6 +759,11 @@ class TestODTExporterBodyMetadataIsText:
that does not fails the export (#7821). The exporter reads report text
with ``yaml_metadata_block`` off, so neither happens, while the title,
author and date still come from the ``--metadata`` arguments.
+ ``multiline_tables`` is off as well: a ``---`` line directly followed
+ by text, with the next rule only after a blank line, stays a
+ horizontal rule instead of a one-column table. A ``---`` line, lines
+ of text and another ``---`` line with no blank line between them are
+ still a simple table, and pipe tables are unaffected.
"""
@pytest.fixture
@@ -792,17 +797,70 @@ class TestODTExporterBodyMetadataIsText:
assert "<dc:title>Report</dc:title>" in meta
assert "2026-01-02" in meta
- def test_rule_directly_followed_by_a_heading_exports(self, exporter):
- """The #7821 shape: a rule directly followed by a heading. Read as
- the start of a YAML block that the footer's rule closes, it made
- pandoc exit with "Error parsing YAML metadata"."""
+ @pytest.mark.parametrize(
+ "markdown",
+ [
+ "Intro text.\n\n---\n## Sources\n\n[1] Example source\n",
+ # The shape topic_organization_strategy.py emits itself.
+ "Intro text.\n\n---\n**Total Sources Organized:** 5\n\n"
+ "## Sources\n\n[1] Example source\n",
+ ],
+ ids=["7821", "topic-organization"],
+ )
+ def test_rule_directly_followed_by_text_is_a_rule(self, exporter, markdown):
+ """The #7821 shape: a rule directly followed by text. Read as the
+ start of a YAML block that the footer's rule closes, it made pandoc
+ exit with "Error parsing YAML metadata". With YAML blocks off,
+ pandoc's ``multiline_tables`` read the same lines as a one-column
+ table: the rest of the report, up to the footer, in one table cell,
+ with its headings as literal ``##`` text. Both rules stay rules and
+ the heading stays a heading."""
+ content = _odt_members(exporter.export(markdown).content)[
+ "content.xml"
+ ].decode("utf-8")
+
+ assert "<table:table" not in content
+ assert "##" not in content
+ assert re.search(
+ r"<text:h [^>]*>(?:<text:bookmark-start [^>]*/>)?Sources"
+ r"(?:<text:bookmark-end [^>]*/>)?</text:h>",
+ content,
+ ), content
+ # This rule and the footer's.
+ assert content.count('text:style-name="Horizontal_20_Line"') >= 2
+ assert "Intro text." in content
+ assert "[1] Example source" in content
+ assert "Open Source AI Research Assistant" in content
+
+ def test_indented_rule_keeps_the_following_lines_whole(self, exporter):
+ """Read as the top of a multiline table, an indented ``---`` line
+ followed by text cut the first characters from every line after
+ it, up to the footer's rule."""
content = _odt_members(
exporter.export(
- "Intro text.\n\n---\n## Sources\n\n[1] Example source\n"
+ "Intro.\n\n ---\nABCDEF line\nGHIJKL line\n\nAfter.\n"
).content
)["content.xml"].decode("utf-8")
- assert "Intro text." in content
- assert "Sources" in content
- assert "[1] Example source" in content
+ assert "<table:table" not in content
+ assert "ABCDEF line GHIJKL line" in content
+ assert ">After.</text:p>" in content
assert "Open Source AI Research Assistant" in content
+
+ @pytest.mark.parametrize(
+ "markdown",
+ [
+ "| Column A | Column B |\n|----------|----------|\n| 1 | two |\n",
+ "---\n 1 two\n 3 four\n---\n",
+ ],
+ ids=["pipe-table", "simple-table"],
+ )
+ def test_ordinary_tables_still_render_as_tables(self, exporter, markdown):
+ """Pipe tables, and a headerless simple table whose rules have no
+ blank line between them, stay tables with ``multiline_tables`` off."""
+ content = _odt_members(exporter.export(markdown).content)[
+ "content.xml"
+ ].decode("utf-8")
+
+ assert "<table:table" in content
+ assert "two" in content
diff --git a/tests/security/test_identity_paths_and_host_effects.py b/tests/security/test_identity_paths_and_host_effects.py
index 89ee76f505..b5292ee140 100644
--- a/tests/security/test_identity_paths_and_host_effects.py
+++ b/tests/security/test_identity_paths_and_host_effects.py
@@ -155,7 +155,7 @@ def test_odt_metadata_cannot_add_pandoc_arguments(
"--sandbox",
"-f",
"markdown-raw_attribute-raw_html-raw_tex"
- "-native_divs-native_spans-yaml_metadata_block",
+ "-native_divs-native_spans-yaml_metadata_block-multiline_tables",
"-t",
"odt",
"-o",
diff --git a/tests/web/services/test_export_generation_contracts.py b/tests/web/services/test_export_generation_contracts.py
index 1a7a9df51c..ea9c36bd1d 100644
--- a/tests/web/services/test_export_generation_contracts.py
+++ b/tests/web/services/test_export_generation_contracts.py
@@ -871,11 +871,11 @@ class TestODTPandocInvocation:
assert cmd[0] == "/usr/bin/pandoc"
assert cmd[cmd.index("-o") + 1] == "-"
- # Raw passthrough, native divs and spans, and body metadata off:
- # report text reaches the ODT as text.
+ # Raw passthrough, native divs and spans, body metadata and
+ # multiline tables off: report text reaches the ODT as text.
assert cmd[cmd.index("-f") + 1] == (
"markdown-raw_attribute-raw_html-raw_tex"
- "-native_divs-native_spans-yaml_metadata_block"
+ "-native_divs-native_spans-yaml_metadata_block-multiline_tables"
)
assert cmd[cmd.index("-t") + 1] == "odt"
assert result.content == b"PK\x03\x04odt-bytes"