feat(chunks): aggiunge parser.py con markdown-it-py
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user