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
+27
View File
@@ -126,3 +126,30 @@ def test_source_line_numbers(cfg):
para = next(b for b in blocks if b.kind == "paragraph")
assert para.start_line == 2
assert para.end_line == 3
def test_math_block_is_atomic(cfg):
md = "# T\n\n$$\nE=mc^2\n$$\n"
tokens, lines = parse(md)
blocks = segment(tokens, lines, cfg)
math = next((b for b in blocks if b.kind == "math"), None)
assert math is not None
assert math.atomic is True
assert "E=mc^2" in math.content
def test_math_block_plain_text(cfg):
md = "# T\n\n$$\n\\int_0^1 f(x) dx\n$$\n"
tokens, lines = parse(md)
blocks = segment(tokens, lines, cfg)
math = next(b for b in blocks if b.kind == "math")
assert math.plain_text == "[formula]"
def test_html_block_with_table(cfg):
md = "# T\n\n<table><tr><td>A</td></tr></table>\n"
tokens, lines = parse(md)
blocks = segment(tokens, lines, cfg)
html = next((b for b in blocks if b.kind == "html"), None)
assert html is not None
assert "<table" in html.content