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

ब्रांड-आइकन प्लगइन के रिज़ॉल्वर को बनाएं

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.