King Hippopotamus

Custom element · any text file · v2.0.0

sst-spawn

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

PropertyValue
Elements<simple-spawn>, <sst-spawn> and <md-spawn>, all registered by one import
DetectionFile type read from the src URL; the type attribute overrides it
MarkdownRendered as GFM
Code and dataHighlighted — js, ts, py, go, rs, java, rb, c, cpp, json, yaml, toml, xml, sql, sh, css
MarkupHTML and SVG rendered inline, after sanitisation
Display modesdefault, book, A4, raw
SanitisationDOMPurify by default
Deferred renderloading="lazy"; optional open shadow root
Dependenciesmarked, DOMPurify, highlight.js
LicenseMIT

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.

Auto

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>
Override

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.

Modes

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>
Compat

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