document-ocr / ocr_studio /export_markdown.py
alirezaaminzadeh's picture
Expand document OCR with PDF support, bilingual UI, and extra exports
98e1d9f verified
Raw
History Blame Contribute Delete
513 Bytes
from __future__ import annotations
from pathlib import Path
def write_markdown_file(
text: str,
destination: Path,
language: str,
mode: str,
page_count: int,
) -> Path:
body = (text or "").strip()
header = (
f"# Document OCR\n\n"
f"- Language: `{language}`\n"
f"- Mode: `{mode}`\n"
f"- Pages: `{page_count}`\n\n"
f"---\n\n"
)
destination.write_text(header + body + "\n", encoding="utf-8")
return destination