Install
openclaw skills install @mina-atef-00/marker-pdfUse when converting scanned PDFs or documents to markdown/JSON/HTML. Marker (Datalab) uses surya OCR for 90+ languages including Arabic.
openclaw skills install @mina-atef-00/marker-pdfConvert PDFs, images, DOCX, PPTX, HTML, EPUB into clean markdown, JSON, or HTML. Uses surya for OCR (90+ languages including Arabic) and layout detection. Optionally uses an LLM for higher accuracy.
Don't use for: Native digital PDFs with good text (just extract text directly).
Don't use for single-page images (use vision_analyze instead).
On immutable systems (Bootc, Silverblue, etc.), use uv inside a container or a venv:
# Option A: uv tool install (isolated, best for CLI use)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv tool install marker-pdf
# Option B: uv venv + pip (if you need Python API access)
uv venv ~/.venvs/marker && source ~/.venvs/marker/bin/activate
uv pip install marker-pdf
# Option C: Podman container (fully isolated)
podman run --rm -v ./pdfs:/data -it python:3.12-slim \
bash -c "pip install marker-pdf && marker_single /data/input.pdf -o /data/output/"
First run downloads ~1GB of ML models to ~/.cache/marker/.
marker_single /path/to/file.pdf -o /path/to/output/
Key flags:
--output_format [markdown|json|html|chunks] — default: markdown--force_ocr — force OCR on all pages (use for scanned PDFs)--strip_existing_ocr — remove existing OCR text, re-OCR with surya--page_range "0,5-10,20" — process specific pages--use_llm — boost accuracy with an LLM (needs API key)--disable_image_extraction — skip image extraction--paginate_output — add page number markers--debug — save debug images with layout overlaysmarker /path/to/input/folder/ -o /path/to/output/ --workers 4
# Force OCR (recommended for scanned Arabic PDFs)
marker_single arabic.pdf -o ./output/ --force_ocr
# With LLM boost for better accuracy
marker_single arabic.pdf -o ./output/ --force_ocr --use_llm \
--llm_service marker.services.gemini.GoogleGeminiService \
--gemini_api_key YOUR_KEY
Surya OCR supports Arabic natively. For scanned documents, always use --force_ocr.
marker_single file.pdf -o ./output/ \
--converter_cls marker.converters.table.TableConverter \
--output_format json
from marker.converters.pdf import PdfConverter
from marker.models import create_model_dict
from marker.output import text_from_rendered
converter = PdfConverter(artifact_dict=create_model_dict())
rendered = converter("input.pdf")
text, _, images = text_from_rendered(rendered)
# text is markdown string
from marker.config.parser import ConfigParser
config = {"output_format": "json", "force_ocr": True}
config_parser = ConfigParser(config)
converter = PdfConverter(
config=config_parser.generate_config_dict(),
artifact_dict=create_model_dict(),
processor_list=config_parser.get_processors(),
renderer=config_parser.get_renderer(),
)
rendered = converter("input.pdf")
| Format | Contents |
|---|---|
| Markdown | Text + images (saved separately) + tables + LaTeX equations + code blocks |
| JSON | Tree of blocks with types, bounding boxes, HTML, images (base64) |
| HTML | Full HTML with img tags, math tags, pre tags |
| Chunks | Flattened list of top-level blocks with full HTML (for RAG) |
--use_llm)| Service | Flag | Key needed |
|---|---|---|
| Gemini (default) | --gemini_api_key | GOOGLE_API_KEY env or flag |
| Ollama | --llm_service marker.services.ollama.OllamaService | --ollama_base_url, --ollama_model |
| Claude | --llm_service marker.services.claude.ClaudeService | --claude_api_key |
| OpenAI | --llm_service marker.services.openai.OpenAIService | --openai_api_key, --openai_model |
--workers if running out of memory--force_ocr for scanned documents--workers or split the PDF into smaller chunks--strip_existing_ocr --force_ocrmodel.safetensors downloaded from models.datalab.to to ~/.cache/datalab/models/layout/<date>/. The connection may break mid-download (BrokenPipeError) — marker retries 3 times automatically. On slow connections, run as a background process (notify_on_complete=true) with a high foreground timeout (600s) so the retry mechanism has room. See references/model-download-pitfalls.md.python3 --versionTORCH_DEVICE=cpu if auto-detect failsMarker output for Arabic scanned PDFs typically has ~85% readable text quality. Common issues:
Run this cleanup AFTER marker_single output. The key patterns to detect and fix:
{N}---------------- and table separators |---|---| — PRESERVE these, they are structuralFor the full reusable cleanup script with all patterns, see references/arabic-ocr-cleanup.md.
End-to-end workflow for scanned Arabic PDFs into an LLM wiki (see also llm-wiki skill):
marker_single "/path/to/document.pdf" \
--output_dir /tmp/marker-output \
--force_ocr \
--paginate_output \
--output_format markdown
Run in background with notify_on_complete=true — model downloads ~1.5GB on first run and can take 10+ minutes.
Apply the cleanup approach above (or the full script in references/). Save cleaned output to raw/papers/ in the wiki:
cp /tmp/marker-output/cleaned-document.md ~/wiki/raw/papers/<subject>.md
llm-wiki skill)Ingest to the target wiki. For a main wiki:
cp /tmp/marker-output/cleaned-document.md ~/wiki/raw/papers/<subject>.md
For a sub-wiki (e.g., academic study wiki under ~/wiki/study/ — see
llm-wiki skill's Multi-Wiki section):
cp /tmp/marker-output/cleaned-document.md ~/wiki/study/raw/papers/<subject>.md
Then:
concepts/ page summarizing the document's topics with sources: frontmatter linked to the raw file — in the same wiki as the raw fileindex.md with a new section link and page count (sub-wiki's index.md)log.md with full pipeline description (sub-wiki's log.md)