@nova-lang/html
v0.1.0
Published
Nova HTML utilities — escaping, sanitization, minification, template helpers
Maintainers
Readme
@nova-lang/html
Nova HTML utilities — escaping, sanitization, minification, and template helpers.
Install
npm install @nova-lang/htmlUsage
@use "nova/html"Escaping
| Function | Description |
|----------|-------------|
| html-escape(text) | Escape HTML entities (<, >, &, ", ') |
| html-unescape(text) | Reverse HTML entity escaping |
| html-escape-attr(text) | Escape for HTML attribute values |
| html-escape-url(url) | Escape for href/src attributes |
| html-strip(text) | Strip all HTML tags |
| html-strip-and-truncate(text, len) | Strip tags + truncate |
Sanitization
| Function | Description |
|----------|-------------|
| html-sanitize(html, tags) | Allow only specified tags |
| html-sanitize-basic(html) | Allow safe tags only (b, i, em, strong, a, p, br, ul, ol, li) |
Attributes & Elements
| Function | Description |
|----------|-------------|
| html-attrs(pairs) | Build HTML attribute string from dict |
| html-class(names) | Build class attribute from array |
| html-style(props) | Build inline style string from dict |
| html-id(prefix) | Generate unique ID with prefix |
| html-data(attrs) | Build data-* attributes from dict |
Meta
| Function | Description |
|----------|-------------|
| html-meta-tags(tags) | Generate <meta> tags from dict |
| html-opengraph(title, desc, image, url) | Generate Open Graph meta tags |
| html-twitter-card(title, desc, image) | Generate Twitter Card meta tags |
Minification
| Function | Description |
|----------|-------------|
| html-minify(html) | Basic HTML minification (collapse whitespace, remove comments) |
| html-indent(html, level) | Pretty-print with indentation |
License
MIT
