diff --git a/.gitignore b/.gitignore index 28ec9b1..8924a81 100644 --- a/.gitignore +++ b/.gitignore @@ -18,12 +18,8 @@ dist/ .qa-fixtures/ .qa-reports/ -# Urheberrechtlich geschützte Beispiel-Bücher und Konvertierungsausgaben +# Urheberrechtlich geschützte Beispiel-Bücher Beispiele/ -buch.epub -buch.md -buch-md/ -medien/ # Editor/OS .idea/ diff --git a/convert_epub2md.sh b/convert_epub2md.sh deleted file mode 100755 index 1a65f95..0000000 --- a/convert_epub2md.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -pandoc buch.epub \ - --from=epub \ - --to=markdown+fenced_code_blocks+backtick_code_blocks+tex_math_dollars+footnotes+pipe_tables \ - --wrap=none \ - --extract-media=medien \ - --output=buch.md - -./split-md-chapters.py buch.md buch-md - diff --git a/split-md-chapters.py b/split-md-chapters.py deleted file mode 100755 index 5e36b3a..0000000 --- a/split-md-chapters.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python3 -import re -import sys -from pathlib import Path - -if len(sys.argv) != 3: - raise SystemExit(f"Aufruf: {sys.argv[0]} EINGABE.md AUSGABE_ORDNER") - -src = Path(sys.argv[1]) -outdir = Path(sys.argv[2]) -outdir.mkdir(parents=True, exist_ok=True) - -text = src.read_text(encoding="utf-8") -parts = re.split(r"(?m)^(?=#\s+)", text) - -def slugify(title: str) -> str: - title = title.lower() - title = re.sub(r"[^\w\s-]", "", title, flags=re.UNICODE) - title = re.sub(r"[\s_-]+", "-", title).strip("-") - return title[:80] or "kapitel" - -index = [] -chapter_no = 0 - -for part in parts: - if not part.strip(): - continue - - m = re.match(r"^#\s+(.+?)\s*$", part, re.M) - if m: - chapter_no += 1 - title = m.group(1).strip() - filename = f"{chapter_no:03d}-{slugify(title)}.md" - else: - filename = "000-vorspann.md" - title = "Vorspann" - - (outdir / filename).write_text(part.rstrip() + "\n", encoding="utf-8") - index.append(f"- [{title}]({filename})") - -(outdir / "README.md").write_text( - "# Inhaltsverzeichnis\n\n" + "\n".join(index) + "\n", - encoding="utf-8", -) -