Expand description
Textlane’s HTML plugins: parsing, hast transforms, sanitizing and serializing.
Structs§
- Autolink
Options - rehype-autolink-headings’ options, JSON values only.
- External
Links html.externalLinks:rel,targetand more on links to other sites, as rehype-external-links adds them; options named as it names them, JSON values only.- 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.- Gemoji
html.gemoji: gemoji shortcodes in text,:smile:, into emoji, asmd.gemojidoes in Markdown.- Highlight
html.highlight: code blocks colored as Shiki colors them, natively by giallo; options named as @shikijs/rehype names them.- Katex
html.katex: math rendered as rehype-katex renders it, natively by katex-rs; options named as KaTeX names them.- Linkify
html.linkify: bare URLs and email addresses in text into links, as GitHub’s literal autolinks do: anhttp,httpsorftpURL as it is, awww.one underhttps://, an email undermailto:; any other scheme stays text.- Math
html.math:$…$and$$…$$in text into the elementshtml.katexrenders, read by pandoc’s rule so prices stay text: an opening$is followed by a non-space, a closing one follows a non-space and is not followed by a digit;\$is a dollar sign.- Minify
Options - rehype-minify-whitespace’s options.
- Parse
html.parse: HTML into hast; options named as rehype-parse names them.- Path
Rewrite html.pathRewrite: the URLs of a document’s attributes as a site serves them, asmd.pathRewritedoes for Markdown: relative ones resolved against the file’s path and made root-relative, every root-relative one underbase, and links to a page’s file turned into its URL.- 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.
- Autolink
html.slug‘sautolink: on, or on with rehype-autolink-headings’ options.- Autolink
Behavior - Where
autolinkputs each heading’s link. - 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.
- Katex
Output - The markup KaTeX writes.
- Katex
Strict - How strictly KaTeX holds input to LaTeX.
- Katex
Strict Mode - One level of KaTeX’s strictness.
- Line
Mark - The classes the lines a
lineAttributesattribute lists get, and maybe its<pre>. - Minify
html.format’sminify: on, or on with rehype-minify-whitespace’s options.- Primitive
- A primitive property value.
- TagNames
- One tag name or several.
- Tokens
- Tokens: a list, or one string of them separated by white space.
- Transformer
Name - The transformers
html.highlightruns natively. - Visit
- What
visit_elementsdoes after its visitor sees an element.
Constants§
- PROSE_
IGNORE - The elements prose plugins leave alone when
ignoreis left out: links, code, scripts, form text and foreign content.
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. - link_
urls - Turn bare URLs and email addresses in text into links: an
http,httpsorftpone as written, awww.one underhttps://, an email undermailto:; any other scheme, and a bare domain, which may name a file, stay text. - mark_
external_ links - Mark each link to another site as rehype-external-links does: its properties,
rel,targetand appended content, in that order. - mark_
math - Turn
$…$and$$…$$in text into the<code class="language-math math-inline">andmath-displayelementsmd.mathmakes, forhtml.katexto render. - 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.
- read_
attribute - An attribute’s value by its HTML name (
class,data-title), as the HTML would spell it:""for a set boolean,Nonewhen unset,falseornull. - read_
text - The text an element renders, as hast-util-to-text’s
toTextreads it. - remove_
attribute - Remove an attribute by its HTML name; whether one was set.
- replace_
shortcodes - Turn the gemoji shortcodes in text,
:rocket:, into their emoji; withaccessible, each in a<span role="img" aria-label="rocket emoji">. - rewrite_
paths - Rewrite the URLs in
options.attributesof every element undernode, written in the file atpath, to the root-relative URLs a site serves them at. - 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.
- typeset_
hast - Render each element of class
language-math,math-displayormath-inlinewith KaTeX as rehype-katex does; a<pre>around alanguage-math<code>is replaced whole. - 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.
- visit_
elements - Call
visitoron every element undernode, in document order, with the tag names of its element ancestors, outermost first. Atemplate’s content is not visited. - write_
attribute - Set an attribute by its HTML name, typed as hast types it:
classbecomes a list, a boolean attributetrue, replacing one already set.