MCPcopy
hub / github.com/marktext/marktext / renderToStaticHTML

Function renderToStaticHTML

packages/muya/src/state/renderToStaticHTML.ts:42–71  ·  view source on GitHub ↗
(
    markdown: string,
    options: IRenderToStaticHTMLOptions = {},
)

Source from the content-addressed store, hash-verified

40 * case it.
41 */
42export 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
73const FOOTNOTE_DEF_RE = /<div class="footnote-block" data-identifier="([^"]*)">([\s\S]*?)<\/div>\s*/g;
74

Callers 4

commonmark.spec.tsFile · 0.90
gfm.spec.tsFile · 0.90

Calls 3

getHighlightHtmlFunction · 0.90
sanitizeFunction · 0.90
transformFootnotesFunction · 0.85

Tested by

no test coverage detected