AI-native document format demonstration — powered by DocLang, Docling and Ollama
DocLang is the AI-native markup format for unstructured content — documents, images, and more. It maps cleanly to LLM tokens while preserving structure, semantics, layout and geometry in a single, unambiguous representation.
"PDF was built for print. DOCX was built for editors. DocLang is built for what comes next."
DocLang is a Joint Development Foundation project under LF AI & Data, founded by IBM, NVIDIA, Red Hat, ABBYY, and HumanSignal.
┌─────────────────────────────────────────────────────────────────┐
│ Browser (UI) │
│ ┌───────────┐ ┌───────────┐ ┌──────────┐ ┌─────────────────┐ │
│ │ Markdown │ │ DocLang │ │ Upload │ │ Ask Ollama │ │
│ │ → DocLang │ │ Editor │ │ Document │ │ (Q&A on docs) │ │
│ └─────┬─────┘ └─────┬─────┘ └────┬─────┘ └────────┬────────┘ │
└────────│─────────────│────────────│───────────────────│─────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────┐
│ Flask API (app.py) │
│ │
│ /api/convert/markdown → markdown_to_doclang() │
│ /api/convert/doclang → doclang_to_html() │
│ /api/validate → validate_doclang() │
│ /api/upload/submit → Docling job started (returns job_id) │
│ /api/upload/status/<id>→ poll job → doclang + preview │
│ /api/ask → Ollama /api/generate │
│ /api/save → output/{name}_{timestamp}.dclg.xml │
│ /api/samples → input/**/*.dclg.xml │
└──────────┬──────────────────────────┬───────────────────────────┘
│ │
▼ ▼
┌─────────────────┐ ┌──────────────────────┐
│ Docling Engine │ │ Ollama (local LLM) │
│ (PDF/DOCX/HTML │ │ llama3.2 / any │
│ → DocLang XML) │ │ model installed │
└─────────────────┘ └──────────────────────┘
Document Input
│
├── Markdown text ──────► markdown_to_doclang() ──────┐
│ │
├── PDF / DOCX / HTML ──► Docling converter ──────────►│
│ │
└── Paste DocLang XML ──────────────────────────────► DocLang XML
│
┌───────────────────┤
│ │
▼ ▼
validate() doclang_to_html()
│ │
▼ ▼
Errors / HTML Preview
Warnings │
▼
Ask Ollama (Q&A)
│
▼
Save → output/
{name}_{timestamp}.dclg.xml
| Feature | Description |
|---|---|
| Markdown → DocLang | Convert Markdown headings, text, lists, tables, and code blocks to DocLang XML |
| DocLang Editor | Write/paste DocLang XML, validate, render, and save |
| Document Upload | Upload PDF, DOCX, or HTML — converted to DocLang via Docling (async, tab-safe) |
| Sample Library | Browse 3 built-in samples from the input/ folder |
| Ask Ollama | Q&A over any DocLang document using a local LLM (llama3.2, etc.) |
| Spec Reference | Quick-reference card for all DocLang elements with comparison table |
| Token Comparison | Live DocLang vs HTML token count comparison |
| Validation | Structural validation against the DocLang spec |
| Dark / Light mode | Toggle in the header (🌙 / ☀️), preference persisted in localStorage, respects prefers-color-scheme |
See Docs/Quickstart.md for full step-by-step instructions.
# 1. Clone and set up
git clone <repo-url> && cd doclang-demo
cp .env.example .env
# 2. Launch
chmod +x scripts/start.sh scripts/stop.sh
./scripts/start.sh
# 3. Open
open http://localhost:8080doclang-demo/
├── app.py # Flask application (backend)
├── requirements.txt # Python dependencies
├── .env.example # Environment variable template
├── .gitignore
│
├── templates/
│ └── index.html # Single-page demo UI
│
├── static/
│ ├── css/style.css
│ └── js/app.js
│
├── input/ # Sample DocLang documents (read-only)
│ ├── 01_financial_report.dclg.xml
│ ├── 02_doclang_spec_summary.dclg.xml
│ └── 03_ml_pipeline_docs.dclg.xml
│
├── output/ # Timestamped saved documents (gitignored)
│
├── tests/
│ └── test_app.py # Unit tests (pytest)
│
├── scripts/
│ ├── start.sh # Launch in detached mode (prints URL)
│ └── stop.sh # Graceful shutdown
│
└── Docs/
├── Quickstart.md
└── Architecture.md
| Endpoint | Method | Description |
|---|---|---|
GET / |
GET | Main demo UI |
/api/convert/markdown |
POST | {markdown} → {doclang, html_preview, tokens} |
/api/convert/doclang |
POST | {doclang} → {html_preview, tokens, validation} |
/api/validate |
POST | {doclang} → {valid, errors, warnings} |
/api/upload/submit |
POST | multipart file → {job_id, filename} (async) |
/api/upload/status/<job_id> |
GET | {status, doclang, html_preview, tokens, error} |
/api/ask |
POST | {question, doclang} → {answer} |
/api/save |
POST | {doclang, filename} → {saved, path} |
/api/samples |
GET | [{name, content}] |
/api/ollama/models |
GET | {models: [...]} |
- 🌐 DocLang website: https://doclang.ai
- 📄 Specification: https://github.com/doclang-project/doclang
- 👁 Official Viewer: https://github.com/doclang-project/viewer
- 💬 Community: https://github.com/doclang-project/community
- 🔧 Docling: https://github.com/docling-project/docling
- 🏛 LF AI & Data: https://lfaidata.foundation
source venv/bin/activate
python -m pytest tests/ -v
pytestis included inrequirements.txtand installed automatically by./scripts/start.sh.
This project is licensed under the MIT License.
MIT License
Copyright (c) 2024 DocLang Demo Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
DocLang itself is an open standard governed by the Linux Foundation / LF AI & Data.