UNPKG

e2ed

Version:

E2E testing framework over Playwright

17 lines (16 loc) 823 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseMarkdownLinks = parseMarkdownLinks; 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 */ function 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}`; }