@itsy/html/create
import { createHtml, SCHEMES } from '@itsy/html/create';
import type { CreateOptions } from '@itsy/html/create';A separate html and attrs, with a different URL scheme list or whitespace rule. The root exports keep the defaults.
createHtml
createHtml(options?: CreateOptions): { html: typeof html; attrs: typeof attrs }export const { html, attrs } = createHtml({ schemes: [...SCHEMES, 'sms'] });Call it once, at module scope
Each call has its own template cache. Calling createHtml inside a component re-scans every template on every render. Create it once and export the result.
CreateOptions
interface CreateOptions {
schemes?: Iterable<string>; // default SCHEMES
collapse?: boolean; // default true
}schemes
The allowed URL schemes, lowercase. It replaces the default set rather than adding to it.
createHtml({ schemes: [...SCHEMES, 'sms'] }); // the defaults plus sms
createHtml({ schemes: ['https'] }); // https and nothing elsecollapse
false keeps line breaks and indentation in the static markup exactly as written, instead of collapsing them to single spaces.
createHtml({ collapse: false });SCHEMES
const SCHEMES: ReadonlySet<string>; // http, https, mailto, tel, data, blobThe default set, exported so it can be spread when needed.
WARNING
frame and wrap() always use SCHEMES. A scheme added here is still blocked in a frame head entry or a wrap() attribute. For a single link, raw() on the whole tag is simpler — see the URL guard.