UNPKG

@uiw/react-markdown-preview

Version:

React component preview markdown text in web browser. The minimal amount of CSS to replicate the GitHub Markdown style.

16 lines (13 loc) 526 B
import type { Plugin } from 'unified'; import { Root, RootContent } from 'hast'; import { visit } from 'unist-util-visit'; export interface ReservedMetaOptions {} export const reservedMeta: Plugin<[ReservedMetaOptions?], Root> = (options = {}) => { return (tree) => { visit(tree, (node: Root | RootContent) => { if (node.type === 'element' && node.tagName === 'code' && node.data && node.data.meta) { node.properties = { ...node.properties, 'data-meta': String(node.data.meta) }; } }); }; };