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
+12 -3
View File
@@ -41,9 +41,18 @@ def _build_chunk(blocks: list[Block], index: int, config: ChunkerConfig,
header_path=header_path,
block_ids=[b.id for b in blocks],
flags={
"has_code": any(b.kind == "code" for b in blocks),
"has_table": any(b.kind == "table" for b in blocks),
"has_math": any(b.kind == "math" for b in blocks),
"has_code": any(b.kind == "code" for b in blocks),
"has_table": any(
b.kind == "table"
or (b.kind == "html" and "<table" in b.content.lower())
for b in blocks
),
"has_math": any(
b.kind == "math"
or "$$" in b.content
or r"\begin{" in b.content
for b in blocks
),
"is_overflow": total_chars > config.max_chars,
"is_sparse": total_chars < config.min_chars,
},