Bedienungsanleitung ergänzt, Bildpfade relativ zur Markdown-Datei

- BEDIENUNGSANLEITUNG.md: Installation, Weg A (PDF -> EPUB), Weg B (Markdown
  bearbeiten, dann pandoc), Scans, Optionen, Prüfen, häufige Probleme;
  Verweis in README.md
- Fix: pymupdf4llm schreibt Bildpfade relativ zum Arbeitsverzeichnis
  ("Output/x_images/…"), wenn der Bilderordner darunter liegt. Die Links
  zeigen jetzt immer relativ zur Markdown-Datei; Regressionstests ergänzt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-10-02 01:23:36 +02:00
commit 85a01ac5c7

View file

@ -13,12 +13,13 @@ from conftest import ROOT, TITLE, needs_pandoc, needs_tesseract
SCRIPT = ROOT / "pdf2md_v5.py"
def run(*args) -> subprocess.CompletedProcess:
def run(*args, cwd=None) -> subprocess.CompletedProcess:
done = subprocess.run(
[sys.executable, str(SCRIPT), *map(str, args)],
capture_output=True,
text=True,
timeout=600,
cwd=cwd,
)
assert done.returncode == 0, done.stderr
return done
@ -128,3 +129,14 @@ def test_png_on_request(pdfs, tmp_path):
run(pdfs["digital"], out, "--images", "--image-format", "png")
md = out.read_text(encoding="utf-8")
assert re.search(r"!\[\]\(png_images/[^)]+\.png\)", md)
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
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)
assert links
for link in links:
assert link.startswith("buch_images/"), link
assert (tmp_path / "Output" / link).is_file()