feat(chunks): aggiunge parser.py con markdown-it-py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-08 16:22:58 +02:00
parent bca01dc1c6
commit 63ca7121b2
2 changed files with 62 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
from __future__ import annotations
from markdown_it import MarkdownIt
from markdown_it.token import Token
def parse(source: str) -> tuple[list[Token], list[str]]:
"""Parsa Markdown in token stream con source map.
Returns:
tokens: lista Token con .map = [start_line, end_line] (0-indexed, end escluso)
lines: righe sorgente (0-indexed) per ricostruzione testo esatto
"""
md = MarkdownIt().enable("table")
tokens = md.parse(source)
lines = source.splitlines()
return tokens, lines