mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
* refactor: improve dx for writing a docs component (#2544) * refactor: improve dx for write a docs component Signed-off-by: Innei <i@innei.in> * refactor(docs): switch to contentlayer2 * chore(docs): rename to avoid conflict * refactor(docs): switch to next-contentlayer2 * refactor(docs): revise docs lib * chore(deps): bump docs related dependencies * fix(use-aria-multiselect): type issue due to ts version bump --------- Signed-off-by: Innei <i@innei.in> Co-authored-by: WK Wong <wingkwong.code@gmail.com> * refactor(docs): accordion codes * feat(docs): declare module `*.jsx?raw` * feat(docs): include `**/*.jsx` * fix(docs): incorrect content * chore(docs): add new lines * refactor(docs): lint --------- Signed-off-by: Innei <i@innei.in> Co-authored-by: Innei <tukon479@gmail.com>
14 lines
434 B
JavaScript
14 lines
434 B
JavaScript
import {unified} from "unified";
|
|
import {toHtml} from "hast-util-to-html";
|
|
import rehypeParse from "rehype-parse";
|
|
|
|
const CALLOUT = /__(.*?)__/g;
|
|
|
|
export default function (code) {
|
|
const html = toHtml(code);
|
|
const result = html.replace(CALLOUT, (_, text) => `<span class="highlight-word">${text}</span>`);
|
|
const hast = unified().use(rehypeParse, {emitParseErrors: true, fragment: true}).parse(result);
|
|
|
|
return hast.children;
|
|
}
|