~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(quarto): disable multiline_tables in Quarto export reader (#8027) (#8070)
HPH Proton3c9449d7a020
diff --git a/changelog.d/8027.bugfix.md b/changelog.d/8027.bugfix.mdnew file mode 100644index 0000000000..7b6164a429--- /dev/null+++ b/changelog.d/8027.bugfix.md@@ -0,0 +1 @@+Quarto 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/text_optimization/citation_formatter.py b/src/local_deep_research/text_optimization/citation_formatter.pyindex 73fff64e82..a6555dcf1a 100644--- a/src/local_deep_research/text_optimization/citation_formatter.py+++ b/src/local_deep_research/text_optimization/citation_formatter.py@@ -1522,7 +1522,18 @@ def _defuse_quarto_cells(body: str) -> str:# line against that. Nor does it read a ``%`` title block: Quarto starts the# body it hands to Pandoc with a line break (``partitionYamlFrontMatter``# in src/core/yaml.ts), which already keeps one from opening, and the-# reader format switches the extension off as well.+# reader format switches the extension off as well. It also switches+# ``multiline_tables`` off. With ``yaml_metadata_block`` off, a ``---``+# line (defused to ``----``) directly followed by text, with the next+# rule only after a blank line, would be a one-column multiline table:+# the report up to that rule, headings included, would sit in one cell,+# and an indented rule would cut the leading characters of every+# following line. 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._QUARTO_READER_FORMAT = "markdown" + "".join(f"-{extension}"for extension in (@@ -1539,6 +1550,7 @@ _QUARTO_READER_FORMAT = "markdown" + "".join("fenced_code_attributes","yaml_metadata_block","pandoc_title_block",+ "multiline_tables",))_ZERO_WIDTH_SPACE = "\u200b"diff --git a/tests/text_optimization/test_citation_formatter_contracts.py b/tests/text_optimization/test_citation_formatter_contracts.pyindex 09f12e3a9c..26e4f6f11c 100644--- a/tests/text_optimization/test_citation_formatter_contracts.py+++ b/tests/text_optimization/test_citation_formatter_contracts.py@@ -2034,6 +2034,10 @@ class TestRegexBounds:"> quoted\n> ---\n> more","Term\n\n: ---\n","Text[^1].\n\n[^1]: ---\n",+ # A rule directly followed by text, closed after a blank line.+ # The four dashes of the defused line must be the same document+ # as the three that were written.+ "---\nParagraph after the first rule.\n\n---",],ids=["prose",@@ -2043,6 +2047,7 @@ class TestRegexBounds:"blockquote","definition","footnote",+ "rule-followed-by-text",],)def test_pandoc_renders_dash_lines_as_written(self, body):@@ -2065,6 +2070,120 @@ class TestRegexBounds:assert rendered == bodyassert "\u2014" in json.dumps(blocks(rendered), ensure_ascii=False)+ @pytest.mark.parametrize(+ "body",+ [+ "---\nParagraph after the first rule.\n\n---",+ "Intro text.\n\n---\n**Total Sources Organized:** 14 across 3"+ " topics\n\n## Sources\n\n[1] Example source\n\n---\nFooter.",+ ],+ ids=["rule-followed-by-text", "topic-organization"],+ )+ def test_pandoc_reads_a_rule_followed_by_text_as_a_rule(self, body):+ """A ``---`` line directly followed by text, with the next rule+ after a blank line, stays two horizontal rules under the exported+ reader.++ ``topic_organization_strategy.py`` emits this shape+ (``\\n---\\n**Total Sources Organized:**``). With+ ``multiline_tables`` on, Pandoc reads the defused ``----`` lines+ as a one-column table and the rest of the section, headings+ included, lands in that cell. This pins the blocks the file's+ ``from`` produces against a control that turns the extension+ back on.+ """+ pypandoc = pytest.importorskip("pypandoc")+ front, rendered = self._qmd_body(body)+ line = next(x for x in front.splitlines() if x.startswith("from:"))+ reader = line[len("from:") :].strip()++ def blocks_of(fmt):+ return json.loads(+ pypandoc.convert_text(rendered, "json", format=fmt)+ )["blocks"]++ control_blocks = blocks_of(reader + "+multiline_tables")+ blocks = blocks_of(reader)+ assert any(b["t"] == "Table" for b in control_blocks), control_blocks+ assert all(b["t"] != "Table" for b in blocks), blocks+ assert [b["t"] for b in blocks].count("HorizontalRule") == 2, [+ b["t"] for b in blocks+ ]+ if "## Sources" in body:+ assert any(b["t"] == "Header" for b in blocks), blocks++ def test_pandoc_keeps_lines_after_an_indented_rule_whole(self):+ """An indented ``---`` followed by text, closed after a blank+ line, does not cut the lines after it.++ Read as a multiline table, the indent of the rule is the column+ start, so ``ABCDEF`` / ``GHIJKL`` become ``CDEF`` / ``IJKL``+ inside one cell. The exported reader keeps both rules and both+ lines whole.+ """+ pypandoc = pytest.importorskip("pypandoc")+ body = "Intro.\n\n ---\nABCDEF line\nGHIJKL line\n\n---\nAfter.\n"+ front, rendered = self._qmd_body(body)+ line = next(x for x in front.splitlines() if x.startswith("from:"))+ reader = line[len("from:") :].strip()++ def blocks_of(fmt):+ return json.loads(+ pypandoc.convert_text(rendered, "json", format=fmt)+ )["blocks"]++ def strings(node):+ found = []++ def walk(value):+ if isinstance(value, dict):+ if value.get("t") == "Str":+ found.append(value["c"])+ for child in value.values():+ walk(child)+ elif isinstance(value, list):+ for child in value:+ walk(child)++ walk(node)+ return found++ control_blocks = blocks_of(reader + "+multiline_tables")+ blocks = blocks_of(reader)+ control_cell = strings(+ [block for block in control_blocks if block["t"] == "Table"]+ )+ assert "CDEF" in control_cell, control_cell+ assert "IJKL" in control_cell, control_cell+ assert "ABCDEF" not in control_cell, control_cell+ assert "GHIJKL" not in control_cell, control_cell+ assert all(b["t"] != "Table" for b in blocks), blocks+ assert [b["t"] for b in blocks].count("HorizontalRule") == 2, [+ b["t"] for b in blocks+ ]+ assert "ABCDEF" in strings(blocks), strings(blocks)+ assert "GHIJKL" in strings(blocks), strings(blocks)++ @pytest.mark.parametrize(+ "body",+ [+ "| Column A | Column B |\n|----------|----------|\n| 1 | two |\n",+ "---\n 1 two\n 3 four\n---\n",+ ],+ ids=["pipe-table", "simple-table"],+ )+ def test_pandoc_still_reads_ordinary_tables(self, body):+ """Pipe tables, and a headerless simple table whose rules have no+ blank line between them, stay tables with ``multiline_tables`` off."""+ pypandoc = pytest.importorskip("pypandoc")+ front, rendered = self._qmd_body(body)+ line = next(x for x in front.splitlines() if x.startswith("from:"))+ reader = line[len("from:") :].strip()+ blocks = json.loads(+ pypandoc.convert_text(rendered, "json", format=reader)+ )["blocks"]+ assert any(b["t"] == "Table" for b in blocks), blocks+@pytest.mark.parametrize("unit",[