(
markdown: string,
options: IRenderToStaticHTMLOptions = {},
)
| 40 | * case it. |
| 41 | */ |
| 42 | export function renderToStaticHTML( |
| 43 | markdown: string, |
| 44 | options: IRenderToStaticHTMLOptions = {}, |
| 45 | ): string { |
| 46 | if (!markdown) |
| 47 | return ''; |
| 48 | |
| 49 | const footnote = options.footnote ?? false; |
| 50 | |
| 51 | let html = getHighlightHtml(markdown, { |
| 52 | footnote, |
| 53 | math: options.math ?? true, |
| 54 | isGitlabCompatibilityEnabled: options.isGitlabCompatibilityEnabled ?? true, |
| 55 | superSubScript: options.superSubScript ?? true, |
| 56 | frontMatter: options.frontMatter ?? false, |
| 57 | }); |
| 58 | |
| 59 | // Post-process footnotes into the standard GFM / pandoc shape (inline |
| 60 | // numbered <sup> + bottom <section class="footnotes"> with backrefs). |
| 61 | // Must run before DOMPurify so the `data-identifier` marker emitted by |
| 62 | // the marked footnote extension is still readable; the default config |
| 63 | // strips `data-*` attributes. |
| 64 | if (footnote) |
| 65 | html = transformFootnotes(html); |
| 66 | |
| 67 | if (options.sanitize === false) |
| 68 | return html; |
| 69 | |
| 70 | return sanitize(html, EXPORT_DOMPURIFY_CONFIG, false) as string; |
| 71 | } |
| 72 | |
| 73 | const FOOTNOTE_DEF_RE = /<div class="footnote-block" data-identifier="([^"]*)">([\s\S]*?)<\/div>\s*/g; |
| 74 |
no test coverage detected