Browser-based viewer for DocLang markup and archives: a reading view, formatted markup, and—when opening an archive with page images—original pages with linked selection and bounding-box overlays.
Standalone .dclg or .xml files show markup and the reading view only. .dclx archives may also include page images and assets; layout and page-alignment rules are in the DocLang specification (archive format section).
Serve this directory over HTTP so the demo can fetch example files:
python3 -m http.server 8080Open http://localhost:8080/ and click Load demo.
| Action | Description |
|---|---|
| Load demo | Fetches assets/2501.17887.dclx (requires HTTP). |
| Open file | Select a .dclx archive, or a standalone .dclg / .xml markup file. |
| Drag and drop | Drop any supported file onto the page. |
| From another page | A page that opens the viewer can hand it a file; see Opening from another page. |
Supported types: .dclx, .dclg, .xml. The demo URL is configured in demo-data.js.
Tools that produce DocLang in the browser, such as the docling-serve UI, can open the viewer with a document already loaded. The file is passed with postMessage, so it never needs a public URL:
- Open the viewer in a new window with
?source=opener(the demo is then not loaded), keeping the returned window handle. - Post
{type: "doclang-viewer:ping"}to it, repeating until the viewer answers{type: "doclang-viewer:ready"}. - Post
{type: "doclang-viewer:open", name, buffer}, wherebufferis the file as anArrayBufferandnameits file name (for examplereport.dclx).
const viewer = window.open("https://doclang.ai/viewer/?source=opener", "_blank");
const origin = "https://doclang.ai";
const ping = setInterval(() => viewer.postMessage({ type: "doclang-viewer:ping" }, origin), 250);
window.addEventListener("message", (event) => {
if (event.source !== viewer || event.data?.type !== "doclang-viewer:ready") return;
clearInterval(ping);
viewer.postMessage({ type: "doclang-viewer:open", name: "report.dclx", buffer }, origin, [buffer]);
});The viewer only accepts these messages from the window that opened it.
demo-data.js— demo archive URLindex.html— shell UIviewer.js— parsing, page alignment, bbox overlayviewer.css— layout and themevendor/katex/— vendored KaTeX (MIT, seevendor/katex/LICENSE), used to render<formula>LaTeX in the reading viewvalidator-worker.mjs— XSD validation in a Web Worker, equivalent todoclang validate --xsd-only -nschema/doclang.xsd— copy of the DocLang XSD from the doclang repo (doclang/doclang.xsd, version 0.7.3)vendor/libxml2-wasm/— vendored libxml2-wasm (MIT, seevendor/libxml2-wasm/LICENSE), libxml2 compiled to WebAssembly, used for validation
