update
This commit is contained in:
@@ -187,6 +187,24 @@ def _parse_fragment(text: str) -> list[dict]:
|
||||
return sections
|
||||
|
||||
|
||||
_GRAFIK_MERMAID_RE = re.compile(r"```(?:mermaid)?\s*\n(.*?)```", re.DOTALL)
|
||||
|
||||
|
||||
def _parse_grafik(text: str) -> dict[str, str]:
|
||||
"""Grafik-Datei → {section-titel: mermaid-code}. Je `<!-- section: titel -->` den ersten
|
||||
```mermaid…```-Block (sonst den Rohtext des Abschnitts)."""
|
||||
out: dict[str, str] = {}
|
||||
parts = re.split(r"<!--\s*section\s*:\s*(.*?)\s*-->", text, flags=re.IGNORECASE)
|
||||
for i in range(1, len(parts), 2):
|
||||
titel = parts[i].strip()
|
||||
body = parts[i + 1] if i + 1 < len(parts) else ""
|
||||
m = _GRAFIK_MERMAID_RE.search(body)
|
||||
code = (m.group(1) if m else body).strip()
|
||||
if titel and code:
|
||||
out[titel] = code
|
||||
return out
|
||||
|
||||
|
||||
def _parse_subbausteine(text: str) -> dict[str, list[str]]:
|
||||
"""Parst eine Subbaustein-Datei → {Baustein-Titel: [Subbaustein, …]} in Reihenfolge.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user