# HTML Document Viewer
HTML Document Viewer is an Obsidian community plugin for viewing static `.html`
and `.htm` files stored in a vault. Each document is treated as untrusted and is
rendered read-only inside a separate sandboxed iframe.
The runtime implements milestones 1–9 from `SPEC.md` plus nested vault assets,
responsive images, CSS image URLs, and dependency-aware refresh. The plugin is published in the Obsidian
Community directory after passing its automated security, dependency,
provenance, and reproducible-build checks.
## Installation and usage
Install **HTML Document Viewer** from **Settings → Community plugins → Browse**.
Enable it, then select an `.html` or `.htm` file in the file explorer. The file
opens read-only in a normal Obsidian pane. It can be split into multiple panes,
and open views refresh when the document or one of its referenced assets
changes.
## Security guarantees
Document markup is never interpreted in Obsidian's DOM. The plugin parses HTML
in a detached document, removes active and navigation-producing content, inserts
a restrictive Content Security Policy (CSP), serializes with `XMLSerializer`,
and assigns only that prepared output to an iframe's `srcdoc` property.
The iframe has an empty `sandbox` attribute. It receives no `allow-scripts`,
`allow-same-origin`, navigation, popup, form, or download permissions. The CSP
also denies scripts, connections, frames, objects, workers, forms, media,
manifests, and every default resource type.
- Inline and external scripts do not run.
- Inline event handlers are removed.
- Forms and non-fragment navigation are disabled.
- HTTP, HTTPS, protocol-relative, `file:`, `app:`, vault-escaping traversal, and
other unsupported document-authored resource references are removed.
- Supported vault raster bytes are rewritten to generated base64 `data:` URLs
only after path normalization, vault lookup, magic-byte validation, and
decoded-dimension limits. Authored raster data URLs receive the same byte and
dimension validation. Stylesheet text is inserted into the detached document
without HTML interpolation.
- Documents are bounded before rendering: HTML source, DOM element count and
depth, authored asset count, decoded image dimensions, individual image and
stylesheet size, aggregate loaded bytes, and embedded output expansion all
have fixed limits. Repeated references share one vault read, and superseded
renders stop before further asset processing.
- Raster references in inline and linked CSS are resolved through the same
vault-only loader. Unsupported or remote CSS URLs are replaced with empty
URLs, and the CSP remains a second no-network boundary.
- The plugin makes no telemetry or network requests.
There is no trusted mode, bypass toggle, or setting that weakens this model.
## Supported content
The current build supports:
- ordinary static HTML;
- static presentation MathML, excluding `annotation-xml` integration content;
- inline CSS in `