Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
12345678910111213141516171819import MarkdownIt from "markdown-it";import sanitizeHtml from "sanitize-html";
const md = new MarkdownIt({ html: false, linkify: true });
const TAGS = ["strong", "em", "s", "code"];
const optionsFor = (links: boolean): sanitizeHtml.IOptions => ({ allowedTags: links ? [...TAGS, "a"] : TAGS, allowedAttributes: { a: ["href", "rel"] }, allowedSchemes: ["http", "https", "mailto"], transformTags: { a: sanitizeHtml.simpleTransform("a", { rel: "nofollow ugc noopener noreferrer" }) }});
export const renderInline = (source: string, links = true): string => sanitizeHtml(md.renderInline(source), optionsFor(links));