2.0.0
on npm
Custom element · any text file · v2.0.0
Renders Markdown, code, JSON, YAML, HTML and SVG from one custom element, detecting the file type from the src URL.
npm install sst-spawn
2.0.0
on npm
63
file types detected
3
tag names registered
MIT
license
What it is
SST — Simple Smart Tag — is md-spawn widened past Markdown. Point the element at any text file and it picks the renderer from the extension: Markdown as GFM, source files as highlighted code, HTML and SVG rendered after sanitisation, data files highlighted as data.
Specification
| Property | Value |
|---|---|
| Elements | <simple-spawn>, <sst-spawn> and <md-spawn>, all registered by one import |
| Detection | File type read from the src URL; the type attribute overrides it |
| Markdown | Rendered as GFM |
| Code and data | Highlighted — js, ts, py, go, rs, java, rb, c, cpp, json, yaml, toml, xml, sql, sh, css |
| Markup | HTML and SVG rendered inline, after sanitisation |
| Display modes | default, book, A4, raw |
| Sanitisation | DOMPurify by default |
| Deferred render | loading="lazy"; optional open shadow root |
| Dependencies | marked, DOMPurify, highlight.js |
| License | MIT |
Recorded session
This package has no CLI to record. The checkable act is the markup below: paste it into an HTML file, point it at a file of any supported type, and the element chooses the renderer itself.
How it works
The element decides two things for you — which renderer to use, and how the result is laid out. Both are overridable in one attribute.
Detection
The extension picks the renderer
And when the extension lies, the type attribute wins.
Read from the src URL
A .md file renders as Markdown, a .py file as highlighted Python, a .json file as highlighted data, an .svg inline after sanitisation. Dockerfile and Makefile are matched by name rather than extension.
<simple-spawn src="/docs/guide.md"></simple-spawn> <simple-spawn src="/src/server.py"></simple-spawn>
Force a renderer
A .txt file holding JSON, or notes that are really Markdown, are the common cases. The type attribute skips detection entirely.
<simple-spawn src="./data.txt" type="json"></simple-spawn>
Layout
Four display modes
Same content, four page shapes.
default, book, A4, raw
default is the styled reading layout; book sets a narrower measure; A4 constrains to a printable page; raw applies no styling at all so your own CSS owns the result.
<simple-spawn src="./report.md" mode="a4"></simple-spawn>
Three tag names, one import
The import registers <simple-spawn>, <sst-spawn> and <md-spawn>. A page already written against md-spawn keeps working after the swap.
import "sst-spawn";
Limits
What this does not do, and where it should not be trusted. These stay on the page whatever else changes.
It runs in the browser only. There is no server-side render path, so a crawler that does not execute JavaScript sees the empty tag.
Detection is by file extension and filename, not by sniffing content. An unrecognised or misleading extension renders as plain text until you set the type attribute.
Rendered HTML and SVG are sanitised, which means they are altered: a document that depends on stripped markup or on inline script will not render the way its author intended.
Rendering, highlighting and sanitisation come from marked, highlight.js and DOMPurify. Their parsing behaviour is this element's behaviour.
This is the same lineage as md-spawn, not a separate engine. Choosing it over md-spawn buys file-type detection and display modes, and nothing else.
The single module script is 1,893,313 bytes: the Markdown parser, the sanitiser and a syntax highlighter with its language grammars are inlined. One request, one large file.
The package declares an npm postinstall script that prints a banner on install (and names md-spawn — a packaging carry-over). It runs code at install time; it will be removed in the next release.
Links
Defects in this package are issues in its own repository.
Author approval — 2026-08-23, hash 2c898971