Expand description
Textlane’s HTML plugins: parsing, hast transforms, sanitizing and serializing.
Structs§
- Extract
Toc html.extractToc: the headings, nested by rank, as the file’sdata.toc, as @stefanprobst/rehype-extract-toc stores them.- Format
html.format: indent and collapse whitespace for readable HTML; options named as hast-util-format names them.- Highlight
html.highlight: code blocks colored as Shiki colors them, natively by giallo; options named as @shikijs/rehype names them.- Parse
html.parse: HTML into hast; options named as rehype-parse names them.- Raw
html.raw: reparse raw HTML and fix nesting through the HTML parser; options named as hast-util-raw names them.- Sanitize
html.sanitize: keep only what a schema allows; options: hast-util-sanitize’s schema, where a field left out keeps the default schema’s, which is GitHub’s.- Slug
html.slug: ids on headings, from their text; options named as rehype-slug names them.- Stringify
html.stringify: hast into HTML; options named as hast-util-to-html names them.- ToMarkdown
html.toMarkdown: hast into mdast; options named as hast-util-to-mdast names them.- ToNatural
Language html.toNaturalLanguage: hast into nlcst, tokenized by the processor’s natural-language parser.- Unwrap
Images html.unwrapImages: paragraphs that hold only images, and links around them, give way to their content, as rehype-unwrap-images does.
Enums§
- Attribute
Definition - A property a sanitize schema allows: by name, or a name and its allowed values.
- Classes
- Class names: a list, or one string of them separated by white space.
- Color
Replacement - A replacement color, or a theme’s own replacements.
- Configured
Transformer - A transformer with its options, as @shikijs/transformers names them.
- Highlight
Transformer - A transformer of @shikijs/transformers: its name alone, or its name and options.
- Indent
- One level of indentation.
- Inline
Code - How inline code names its language.
- Primitive
- A primitive property value.
- Transformer
Name - The transformers
html.highlightruns natively.
Functions§
- bridge_
hast - hast into nlcst, as hast-util-to-nlcst does: each paragraph or heading, and each run of
phrasing content in an element that accepts flow, becomes a paragraph, with
sourcethe text the tree was parsed from. - convert_
hast - Turn hast into mdast, as hast-util-to-mdast does after collapsing whitespace as rehype-minify-whitespace does; several nodes come back in a root.
- extract_
toc - The headings of a tree as @stefanprobst/rehype-extract-toc nests them: each
{depth, value, id?, children?}, under the closest heading of a lower rank before it. - format_
hast - Format whitespace in a hast tree for reading, as hast-util-format does: collapse it, then put each block on its own line, indented by how deep it nests.
- highlight_
hast - Color each
<pre>whose first child is a<code class="language-…">as @shikijs/rehype does, replacing the block with Shiki’s. - parse_
html - Parse HTML into hast as parse5 and hast-util-from-html do, recording parse errors on
filewhenemit_parse_errorsis set. - raw_
hast - Pass a hast tree through the HTML parser, as hast-util-raw does: raw nodes become real nodes and nesting is fixed.
- sanitize_
hast - Keep only what a schema allows of a hast tree, as hast-util-sanitize does.
- slug_
hast - Give headings without an
idone made from their text, as rehype-slug does. - stringify_
hast - Serialize hast as HTML, as hast-util-to-html does.
- unwrap_
images - Put the content of each paragraph that holds only images, links around them and white space in its place, as rehype-unwrap-images does.