Skip to content

pantoken / renderers/rehype/src / rehypePantokenIcons

Functie: rehypePantokenIcons()

rehypePantokenIcons(options?): (tree) => void

Experimenteel

Een rehype-pluginfabriek. Geeft een transformer terug die :code: tokens herschrijft naar inline SVG.

Parameters

options?

RehypeOptions = {}

RehypeOptions.

Retourneert

Een unified/rehype-transformer.

(tree) => void

Voorbeelden

Ingebouwde pictogramset

ts
import { unified } from "unified";
import rehypeParse from "rehype-parse";
import rehypeRaw from "rehype-raw";
import rehypeStringify from "rehype-stringify";
import { rehypePantokenIcons } from "@pantoken/rehype";

const html = await unified()
  .use(rehypeParse, { fragment: true })
  .use(rehypePantokenIcons)
  .use(rehypeRaw) // required: the icon body is a raw SVG node
  .use(rehypeStringify)
  .process("go :arrow-left: back");

Stel de resolver van een brand-icon-plugin samen

ts
import { rehypePantokenIcons } from "@pantoken/rehype";
import { simpleIcons } from "@pantoken/plugin-simple-icons";
import * as registry from "simple-icons";

unified().use(rehypePantokenIcons, { plugins: [simpleIcons({ registry })] });
// :github: now resolves from simple-icons; unknown codes stay literal text.