Skip to content

pantoken / renderers/rehype/src / rehypePantokenIcons

פונקציה: rehypePantokenIcons()

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

ניסיוני

מפעל פלאגין של rehype. מחזיר טרנספורמר שממירה את הטוקנים :code: ל‑SVG מוטמע.

פרמטרים

options?

RehypeOptions = {}

RehypeOptions.

מחזיר

טרנספורמר של unified/rehype.

(tree) => void

דוגמאות

ערכת אייקונים מובנית

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");

הרכב את ה-resolver של תוסף brand-icon

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.