for-legacy-web/src/components/markdown/plugins/htmlEntities.ts

11 lines
300 B
TypeScript

import { Plugin } from "unified";
import { visit } from "unist-util-visit";
export const remarkHtmlEntities: Plugin = () => {
return (tree) => {
visit(tree, "text", (node: { value: string }) => {
node.value = node.value.replace(/</g, "&lt;");
});
};
};