Skip to main content

Crate textlane_html

Crate textlane_html 

Source
Expand description

Textlane’s HTML plugins: parsing, hast transforms, sanitizing and serializing.

Structs§

AutolinkOptions
rehype-autolink-headings’ options, JSON values only.
ExternalLinks
html.externalLinks: rel, target and more on links to other sites, as rehype-external-links adds them; options named as it names them, JSON values only.
ExtractToc
html.extractToc: the headings, nested by rank, as the file’s data.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, as md.gemoji does 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: an http, https or ftp URL as it is, a www. one under https://, an email under mailto:; any other scheme stays text.
Math
html.math: $…$ and $$…$$ in text into the elements html.katex renders, 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.
MinifyOptions
rehype-minify-whitespace’s options.
Parse
html.parse: HTML into hast; options named as rehype-parse names them.
PathRewrite
html.pathRewrite: the URLs of a document’s attributes as a site serves them, as md.pathRewrite does for Markdown: relative ones resolved against the file’s path and made root-relative, every root-relative one under base, 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.
ToNaturalLanguage
html.toNaturalLanguage: hast into nlcst, tokenized by the processor’s natural-language parser.
UnwrapImages
html.unwrapImages: paragraphs that hold only images, and links around them, give way to their content, as rehype-unwrap-images does.

Enums§

AttributeDefinition
A property a sanitize schema allows: by name, or a name and its allowed values.
Autolink
html.slug‘s autolink: on, or on with rehype-autolink-headings’ options.
AutolinkBehavior
Where autolink puts each heading’s link.
Classes
Class names: a list, or one string of them separated by white space.
ColorReplacement
A replacement color, or a theme’s own replacements.
ConfiguredTransformer
A transformer with its options, as @shikijs/transformers names them.
HighlightTransformer
A transformer of @shikijs/transformers: its name alone, or its name and options.
Indent
One level of indentation.
InlineCode
How inline code names its language.
KatexOutput
The markup KaTeX writes.
KatexStrict
How strictly KaTeX holds input to LaTeX.
KatexStrictMode
One level of KaTeX’s strictness.
LineMark
The classes the lines a lineAttributes attribute lists get, and maybe its <pre>.
Minify
html.format’s minify: 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.
TransformerName
The transformers html.highlight runs natively.
Visit
What visit_elements does after its visitor sees an element.

Constants§

PROSE_IGNORE
The elements prose plugins leave alone when ignore is 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 source the 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, https or ftp one as written, a www. one under https://, an email under mailto:; 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, target and appended content, in that order.
mark_math
Turn $…$ and $$…$$ in text into the <code class="language-math math-inline"> and math-display elements md.math makes, for html.katex to render.
parse_html
Parse HTML into hast as parse5 and hast-util-from-html do, recording parse errors on file when emit_parse_errors is 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, None when unset, false or null.
read_text
The text an element renders, as hast-util-to-text’s toText reads 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; with accessible, each in a <span role="img" aria-label="rocket emoji">.
rewrite_paths
Rewrite the URLs in options.attributes of every element under node, written in the file at path, 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 id one 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-display or math-inline with KaTeX as rehype-katex does; a <pre> around a language-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 visitor on every element under node, in document order, with the tag names of its element ancestors, outermost first. A template’s content is not visited.
write_attribute
Set an attribute by its HTML name, typed as hast types it: class becomes a list, a boolean attribute true, replacing one already set.