Inhaltsverzeichnis als Tabelle erhalten, Doku nach Probeläufen ergänzt

- normalize_markdown: Tabellenzeilen im Inhaltsverzeichnis unverändert
  übernehmen; der Verzeichnis-Modus endet mit der Tabelle (sonst zerfiel
  die Tabelle und die folgende Überschrift "Vorwort" ging verloren)
- Test für Verzeichnis als Tabelle
- README/Bedienungsanleitung: weiche Trennstriche, Courier-OCR-Ebenen,
  englische Bücher, --ocr always für alte Scans, Grenzen aus den
  Probeläufen mit fremden PDFs
- TODO.md: bekannte Schwächen (Zahlen als Überschrift, römische
  Seitenzahlen, gesperrte Überschriften)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-10-02 14:24:58 +02:00
commit f9dfa3a52e

View file

@ -303,6 +303,7 @@ def normalize_markdown(
fence_length = 0
in_contents = False
contents_seen: set[str] = set() # Titel, die im Inhaltsverzeichnis standen
contents_table = False # Inhaltsverzeichnis liegt als Markdown-Tabelle vor
headings_seen: set[str] = set()
def paragraph_open() -> bool:
@ -375,6 +376,7 @@ def normalize_markdown(
if CONTENTS_TITLE.match(text):
heading(len(match.group(1)) if match else 2, text)
in_contents = True
contents_table = False
continue
if match:
@ -408,7 +410,21 @@ def normalize_markdown(
continue
if in_contents:
if ends_sentence(text) and len(text) > 80:
if stripped.startswith("|"):
# Verzeichnis als Tabelle: Zeilen unverändert übernehmen,
# sonst zerfällt die Tabelle in einzelne Absätze.
if not contents_table:
flush_paragraph()
blank_line()
contents_table = True
for cell in stripped.strip("|").split("|"):
contents_seen.add(norm_title(cell))
result.append(line)
continue
if contents_table:
in_contents = False # Tabelle zu Ende: Fließtext folgt
blank_line()
elif ends_sentence(text) and len(text) > 80:
in_contents = False # erster Fließtext nach dem Verzeichnis
else:
for entry in split_contents_line(stripped, titles):