UNPKG

e2ed

Version:

E2E testing framework over Playwright

18 lines (17 loc) 864 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseMarkdownLinks = void 0; const sanitizeHtml_1 = require("./sanitizeHtml"); const createSafeHtmlWithoutSanitize = sanitizeHtml_1.createSafeHtmlWithoutSanitize; const sanitizeHtml = sanitizeHtml_1.sanitizeHtml; /** * Parses markdown links in template string and returns sanitized HTML. * This client function should not use scope variables (except global functions). * @internal */ const parseMarkdownLinks = (stringParts, ...values) => { const sanitizedHtml = sanitizeHtml(stringParts, ...values); const htmlWithLinks = sanitizedHtml.replace(/\[(?<name>[^\]]+)\]\((?<href>[^)]+)\)/g, '<a href="$<href>" rel="noreferrer" target="_blank">$<name></a>'); return createSafeHtmlWithoutSanitize `${htmlWithLinks}`; }; exports.parseMarkdownLinks = parseMarkdownLinks;