Personal no-bs blogging platform.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839import DOMPurify from 'isomorphic-dompurify';
import rehypeRaw from 'rehype-raw';import rehypeSanitize from 'rehype-sanitize';import rehypeStringify from 'rehype-stringify';
import remarkParse from 'remark-parse';import remarkRehype from 'remark-rehype';
var strip = require('remark-strip-html');
import { unified } from 'unified';
const processor = unified() .use(remarkParse) .use(remarkRehype, { allowDangerousHtml: true, }) .use(rehypeRaw) // Parse raw html. .use(rehypeSanitize) // sanitize HTML AST. .use(rehypeStringify); // HAST to string.
export async function render_md(input: string) { const sanitized_html = String(await processor.process(input));
const remove_tags = String( await unified() .use(remarkParse) .use(strip) // remove tags from markdown. .use(remarkRehype) // mdast to HAST. .use(rehypeStringify) // HAST to html. .process(input) );
return { sanitized_html, remove_tags, };}