feat(chunks): rilevamento universale has_math/has_table + dollarmath plugin

- parser.py: integra dollarmath_plugin (graceful fallback) — blocchi $$…$$ → token math_block atomico
- segmenter.py: gestisce math_block → Block(kind=math, atomic=True, plain_text=[formula])
- packer.py: has_table rileva anche <table> in blocchi html; has_math rileva $$ e \begin{ nel contenuto
- +11 test (parser×3, segmenter×3, packer×5) — totale 65 test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-09 08:40:41 +02:00
parent 1980efb0d6
commit 3b61df73d3
6 changed files with 121 additions and 3 deletions
+23
View File
@@ -44,3 +44,26 @@ def test_lines_preserves_source():
_, lines = parse(md)
assert lines[0] == "Riga 1"
assert lines[1] == "Riga 2"
def test_parse_math_block():
md = "# T\n\n$$\nE=mc^2\n$$\n"
tokens, lines = parse(md)
types = [t.type for t in tokens]
assert "math_block" in types
def test_math_block_has_source_map():
md = "# T\n\n$$\nE=mc^2\n$$\n"
tokens, lines = parse(md)
mb = next(t for t in tokens if t.type == "math_block")
assert mb.map is not None
assert "E=mc^2" in mb.content
def test_parse_math_inline_stays_in_paragraph():
md = "Testo con $x^2$ inline.\n"
tokens, lines = parse(md)
types = [t.type for t in tokens]
assert "paragraph_open" in types
assert "math_block" not in types