update
This commit is contained in:
@@ -63,13 +63,6 @@ def _load_subbausteine(topic: str) -> dict[str, list[dict]]:
|
||||
return out
|
||||
|
||||
|
||||
def _section_markup(sec: dict) -> str:
|
||||
"""Section-Text mit Sub-Markern (für Lese-Check/Fix), damit die Struktur erhalten bleibt."""
|
||||
if not sec.get("subs"):
|
||||
return sec["md"]
|
||||
return "\n\n".join(f"<!-- sub: {s['stufe']} | {s['titel']} -->\n{s['md']}" for s in sec["subs"])
|
||||
|
||||
|
||||
def _zuteilung_subs(chunk: list[dict], entries: dict[int, str], subs_by_titel: dict[str, list[dict]]) -> str:
|
||||
"""Wie _zuteilung_text, aber listet pro Baustein seine Subbausteine mit Stufe."""
|
||||
lines: list[str] = []
|
||||
@@ -654,11 +647,11 @@ async def _generate_sections(
|
||||
chunk_nums = [[num for ch in chunk for num in ch["nums"] if num in by_num] for chunk in chunks]
|
||||
|
||||
def sections_text(nums: list[int]) -> str:
|
||||
return "\n\n".join(f"SECTION: {_titel(entries[num])}\n{_section_markup(by_num[num])}" for num in nums)
|
||||
return "\n\n".join(f"SECTION: {_titel(entries[num])}\n{by_num[num]['md']}" for num in nums)
|
||||
|
||||
def auftraege_text(nums: list[int], probleme: dict[int, str]) -> str:
|
||||
return "\n\n".join(
|
||||
f"SECTION: {_titel(entries[num])}\nPROBLEM: {probleme[num]}\nAKTUELLER INHALT:\n{_section_markup(by_num[num])}"
|
||||
f"SECTION: {_titel(entries[num])}\nPROBLEM: {probleme[num]}\nAKTUELLER INHALT:\n{by_num[num]['md']}"
|
||||
for num in nums
|
||||
)
|
||||
|
||||
@@ -740,16 +733,12 @@ async def _generate_sections(
|
||||
scope = [[num for num in nums if num in ersetzt] for nums in chunk_nums]
|
||||
|
||||
await _set_progress(guide_id, "Setze zusammen…")
|
||||
def _section(num: int) -> dict:
|
||||
sec = by_num[num]
|
||||
d = {"num": num, "title": _titel(entries[num]), "md": sec["md"]}
|
||||
if sec.get("subs"):
|
||||
d["subbausteine"] = [{"stufe": s["stufe"], "titel": s["titel"], "md": s["md"]} for s in sec["subs"]]
|
||||
return d
|
||||
|
||||
chapters: list[dict] = []
|
||||
for ch in plan:
|
||||
sections = [_section(num) for num in ch["nums"] if num in by_num]
|
||||
sections = [
|
||||
{"num": num, "title": _titel(entries[num]), "md": by_num[num]["md"]}
|
||||
for num in ch["nums"] if num in by_num
|
||||
]
|
||||
if sections:
|
||||
chapters.append({"title": ch["title"], "sections": sections})
|
||||
geplant = {num for ch in plan for num in ch["nums"]}
|
||||
|
||||
Reference in New Issue
Block a user