()
| 93 | |
| 94 | // render pure html by marked |
| 95 | async renderHtml() { |
| 96 | let html = getHighlightHtml(this.markdown, { |
| 97 | superSubScript: this.muya?.options?.superSubScript ?? true, |
| 98 | footnote: this.muya?.options?.footnote ?? false, |
| 99 | isGitlabCompatibilityEnabled: |
| 100 | this.muya?.options?.isGitlabCompatibilityEnabled ?? true, |
| 101 | math: this.muya?.options?.math ?? true, |
| 102 | }); |
| 103 | |
| 104 | html = sanitize(html, EXPORT_DOMPURIFY_CONFIG, false) as string; |
| 105 | |
| 106 | const exportContainer = (this._exportContainer |
| 107 | = document.createElement('div')); |
| 108 | exportContainer.classList.add('mu-render-container'); |
| 109 | exportContainer.innerHTML = html; |
| 110 | document.body.appendChild(exportContainer); |
| 111 | |
| 112 | // render only render the light theme of mermaid and diagram... |
| 113 | await this.renderMermaid(); |
| 114 | await this.renderDiagram(); |
| 115 | let result = exportContainer.innerHTML; |
| 116 | exportContainer.remove(); |
| 117 | |
| 118 | // hack to add arrow marker to output html |
| 119 | // TODO: JOCS, are these codes still needed? |
| 120 | const paths = document.querySelectorAll('path[id^=raphael-marker-]'); |
| 121 | const def = '<defs style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">'; |
| 122 | result = result.replace(def, () => { |
| 123 | let str = ''; |
| 124 | for (const path of paths) |
| 125 | str += path.outerHTML; |
| 126 | |
| 127 | return `${def}${str}`; |
| 128 | }); |
| 129 | |
| 130 | this._exportContainer = null; |
| 131 | |
| 132 | return `<article class="markdown-body">${result}</article>`; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Get HTML with style |
no test coverage detected