diff --git a/BEDIENUNGSANLEITUNG.md b/BEDIENUNGSANLEITUNG.md index dbea778..f87b9a7 100644 --- a/BEDIENUNGSANLEITUNG.md +++ b/BEDIENUNGSANLEITUNG.md @@ -1,6 +1,6 @@ -# Bedienungsanleitung: pdf2md_v5.py – PDF → Markdown → EPUB +# Bedienungsanleitung: pdf2md.py – PDF → Markdown → EPUB -`pdf2md_v5.py` wandelt PDF-Bücher in sauberes Markdown um: echte Absätze, Überschriften mit +`pdf2md.py` wandelt PDF-Bücher in sauberes Markdown um: echte Absätze, Überschriften mit richtiger Ebene, Bilder und ohne Seitenzahlen. Daraus entsteht auf Wunsch direkt ein EPUB für den PocketBook-Reader. Das funktioniert mit digitalen PDFs (Text lässt sich markieren) ebenso wie mit gescannten PDFs (nur Seitenbilder, der Text wird per OCR erkannt). @@ -31,7 +31,7 @@ Prüfen, ob alles da ist: ```bash tesseract --list-langs # muss "deu" enthalten pandoc --version # Version 3.x -python3 pdf2md_v5.py --help # zeigt alle Optionen +python3 pdf2md.py --help # zeigt alle Optionen ``` --- @@ -40,7 +40,7 @@ python3 pdf2md_v5.py --help # zeigt alle Optionen ```bash cd ~/Downloads/ljutsch -python3 pdf2md_v5.py --epub Operation_Ljutsch_Band_1_-_Reinhard_Otto_Kranz.pdf Output/band1.md +python3 pdf2md.py --epub Operation_Ljutsch_Band_1_-_Reinhard_Otto_Kranz.pdf Output/band1.md ``` Das Programm meldet zuerst, was es in der PDF gefunden hat: @@ -80,7 +80,7 @@ EPUB zum Vergleichen: ```bash cd ~/Downloads/ljutsch -python3 pdf2md_v5.py --epub Operation_Ljutsch_Band_1_-_Reinhard_Otto_Kranz.pdf Output/band1.md +python3 pdf2md.py --epub Operation_Ljutsch_Band_1_-_Reinhard_Otto_Kranz.pdf Output/band1.md ``` Wenn du kein Cover und kein Probe-EPUB brauchst, reicht `--images` statt `--epub`. @@ -144,7 +144,7 @@ pandoc band1.md \ --epub-cover-image band1_images/cover.jpg ``` -Das sind dieselben Einstellungen, die `pdf2md_v5.py --epub` verwendet. Titel und Autor trägst du +Das sind dieselben Einstellungen, die `pdf2md.py --epub` verwendet. Titel und Autor trägst du selbst ein. Ohne Cover lässt du die letzte Zeile weg und entfernst den `\` am Ende der Zeile davor. Schritt 2 und 3 kannst du beliebig oft wiederholen. **Achtung:** Schritt 1 erneut auszuführen @@ -158,7 +158,7 @@ Dateinamen. Bei Scans liest das Programm den Text per OCR (Tesseract). Der Aufruf ist derselbe: ```bash -python3 pdf2md_v5.py --epub scan.pdf Output/scan.md +python3 pdf2md.py --epub scan.pdf Output/scan.md ``` | Situation | Option | diff --git a/CLAUDE.md b/CLAUDE.md index 6e8a555..353b813 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,19 +1,19 @@ # CLAUDE.md PDF → Markdown → EPUB für den PocketBook-Reader (digitale und gescannte PDFs). -Aktuelles Programm: `pdf2md_v5.py` (Einzeldatei). v1–v4 sind Historie, nicht ändern. +Aktuelles Programm: `pdf2md.py` (Einzeldatei; Name bleibt fest, keine Versionsnummer im Dateinamen). v1–v4 liegen in `History/` (Historie, nicht ändern). ## Befehle - Tests: `python3 -m pytest` (Fixtures werden synthetisch erzeugt; OCR braucht `tesseract-ocr-deu`) -- Lint: `python3 -m ruff check pdf2md_v5.py tests/` -- Echttest: `python3 pdf2md_v5.py --epub Operation_Ljutsch_Band_1_-_Reinhard_Otto_Kranz.pdf /band1.md` +- Lint: `python3 -m ruff check pdf2md.py tests/` +- Echttest: `python3 pdf2md.py --epub Operation_Ljutsch_Band_1_-_Reinhard_Otto_Kranz.pdf /band1.md` ## Konventionen - Hilfetexte, Meldungen, Kommentare und Docstrings auf Deutsch (wie v4); Bezeichner Englisch. - Echttests nie nach `Fertig/` schreiben (dort liegen die Ergebnisse des Nutzers). - PDFs/EPUBs/Bilder sind per `.gitignore` ausgeschlossen – keine Binärdateien committen. -- `pdf2md_v5.py` patcht zwei Funktionen in `pymupdf4llm.helpers.document_layout` +- `pdf2md.py` patcht zwei Funktionen in `pymupdf4llm.helpers.document_layout` (`get_styled_text`, `text_to_md`). Nach einem pymupdf4llm-Update prüfen, ob `tests/test_normalize.py::test_pymupdf4llm_patch_keeps_compound_hyphen` noch grün ist. diff --git a/pdf2md_v1.py b/History/pdf2md_v1.py similarity index 100% rename from pdf2md_v1.py rename to History/pdf2md_v1.py diff --git a/pdf2md_v2.py b/History/pdf2md_v2.py similarity index 100% rename from pdf2md_v2.py rename to History/pdf2md_v2.py diff --git a/pdf2md_v3.py b/History/pdf2md_v3.py similarity index 100% rename from pdf2md_v3.py rename to History/pdf2md_v3.py diff --git a/pdf2md_v4.py b/History/pdf2md_v4.py similarity index 100% rename from pdf2md_v4.py rename to History/pdf2md_v4.py diff --git a/README.md b/README.md index 115aa02..6cfa4c9 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,13 @@ dann EPUB“: **[BEDIENUNGSANLEITUNG.md](BEDIENUNGSANLEITUNG.md)**. ```bash # digitales oder gescanntes PDF -> Markdown (OCR wird automatisch entschieden) -python3 pdf2md_v5.py buch.pdf buch.md +python3 pdf2md.py buch.pdf buch.md # zusätzlich Bilder und EPUB (Titel/Autor aus den PDF-Metadaten, Seite 1 als Cover) -python3 pdf2md_v5.py --epub buch.pdf buch.md +python3 pdf2md.py --epub buch.pdf buch.md # Scan in Deutsch und Englisch, 8 parallele OCR-Prozesse -python3 pdf2md_v5.py --ocr-language deu+eng --jobs 8 scan.pdf scan.md +python3 pdf2md.py --ocr-language deu+eng --jobs 8 scan.pdf scan.md ``` | Option | Bedeutung | @@ -67,7 +67,7 @@ synthetisch erzeugt. ## Grenzen - Die Ergebnisqualität hängt von pymupdf4llm/pymupdf-layout ab. Zwei Schwächen der - Bibliothek gleicht `pdf2md_v5.py` per Patch aus (Bindestriche am Zeilenende, Absätze in + Bibliothek gleicht `pdf2md.py` per Patch aus (Bindestriche am Zeilenende, Absätze in Scan-Blöcken). Eine weitere ist bekannt: Bei Schriften mit Ligaturen (ff, fi) mit übergroßer Glyphenbox kann pymupdf4llm einzelne Zeilen verlieren. Bei den Ljutsch-Bänden tritt das nicht auf (geprüft per Wortabgleich PDF ↔ Markdown). @@ -76,7 +76,7 @@ synthetisch erzeugt. ## Dateien -- `pdf2md_v5.py` – aktuelle Version -- `pdf2md_v1.py` … `pdf2md_v4.py` – frühere Entwicklungsstände (siehe `Info/`) +- `pdf2md.py` – aktuelle Version +- `History/pdf2md_v1.py` … `History/pdf2md_v4.py` – frühere Entwicklungsstände (siehe `Info/`) - `Info/` – Recherche und Entstehungsgeschichte der Skripte - `tests/` – pytest-Suite diff --git a/TODO.md b/TODO.md index f3c396a..23588e6 100644 --- a/TODO.md +++ b/TODO.md @@ -38,7 +38,7 @@ speichern. Damit lassen sich: - EPUB aus den Einzeldateien: pandoc nimmt mehrere Eingabedateien in der Reihenfolge von `index.md`; Umsortieren = Reihenfolge im Index ändern. -**Ansatzpunkte im Code (`pdf2md_v5.py`):** +**Ansatzpunkte im Code (`pdf2md.py`):** - Schnitt **nach** `normalize_markdown()` an den Überschriften `##` (Teil) und `###` (Kapitel); die Ebenen kommen aus `load_outline()`. diff --git a/ljutsch_meta.xml b/ljutsch_meta.xml deleted file mode 100644 index 670cce1..0000000 --- a/ljutsch_meta.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - ljutsch - texts - opensource - community - Reinhard Otto Kranz<br /> - Internet Archive HTML5 Uploader 1.6.4 - ljutsch - Ljutsch - schamhaar.friseur@gmail.com - 2022-05-30 15:09:50 - 2022-05-30 15:09:50 - http://archive.org/details/ljutsch - ark:/13960/s2jf47qc96n - 300 - [curator]validator@archive.org[/curator][date]20220530154119[/date][comment]checked for malware[/comment] - tesseract 5.0.0-1-g862e - -l deu+Latin - 0.0.15 - true - Latin - 1.0000 - de - 1.0000 - deu - diff --git a/pdf2md_v5.py b/pdf2md.py similarity index 100% rename from pdf2md_v5.py rename to pdf2md.py diff --git a/tests/test_classify.py b/tests/test_classify.py index adc8dbd..b6dbe5c 100644 --- a/tests/test_classify.py +++ b/tests/test_classify.py @@ -3,7 +3,7 @@ import pymupdf import pytest -import pdf2md_v5 as p +import pdf2md as p from conftest import needs_tesseract diff --git a/tests/test_e2e.py b/tests/test_e2e.py index 9cbed2b..76ac589 100644 --- a/tests/test_e2e.py +++ b/tests/test_e2e.py @@ -10,7 +10,7 @@ import pytest from conftest import ROOT, TITLE, needs_pandoc, needs_tesseract -SCRIPT = ROOT / "pdf2md_v5.py" +SCRIPT = ROOT / "pdf2md.py" def run(*args, cwd=None) -> subprocess.CompletedProcess: @@ -132,7 +132,7 @@ def test_png_on_request(pdfs, tmp_path): def test_image_links_relative_to_markdown_with_relative_output(pdfs, tmp_path): - # Aufruf wie "python3 pdf2md_v5.py --images buch.pdf Output/buch.md" aus dem Projektordner + # Aufruf wie "python3 pdf2md.py --images buch.pdf Output/buch.md" aus dem Projektordner run(pdfs["digital"], "Output/buch.md", "--images", cwd=tmp_path) md = (tmp_path / "Output" / "buch.md").read_text(encoding="utf-8") links = re.findall(r"!\[\]\(([^)]+)\)", md) diff --git a/tests/test_normalize.py b/tests/test_normalize.py index 001e9a2..0098d45 100644 --- a/tests/test_normalize.py +++ b/tests/test_normalize.py @@ -5,7 +5,7 @@ from pathlib import Path import pymupdf import pytest -import pdf2md_v5 as p +import pdf2md as p def norm(md: str, outline=None, **kwargs) -> str: