|
11 | 11 | // https://github.com/markedjs/marked |
12 | 12 | //=========================================================================== |
13 | 13 |
|
14 | | -function loadMarkDownScript(callback) { |
| 14 | +function load_marked_script(callback) { |
15 | 15 | var script = document.createElement('script'); |
16 | 16 | //script.src = "https://cdn.jsdelivr.net/npm/marked/marked.min.js"; |
17 | 17 | script.src = "https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.js"; |
18 | 18 | script.type = "text/javascript"; |
19 | | - script.onload = callback; |
| 19 | + script.onload = callback; |
20 | 20 | document.head.appendChild(script); |
21 | 21 | } |
22 | 22 |
|
| 23 | +function load_highlight_script(callback) { |
| 24 | + var script = document.createElement('script'); |
| 25 | + script.src = "https://cdn.jsdelivr.net/npm/highlight.js/lib/highlight.js"; |
| 26 | + script.type = "text/javascript"; |
| 27 | + script.onload = callback; |
| 28 | + document.head.appendChild(script); |
| 29 | +} |
| 30 | + |
| 31 | +function load_highlight_link_stylesheet() { |
| 32 | + var link = document.createElement('link'); |
| 33 | + link.href = "https://cdn.jsdelivr.net/npm/highlight.js/styles/github.css"; |
| 34 | + link.rel = "stylesheet"; |
| 35 | + document.head.appendChild(link); |
| 36 | +} |
| 37 | + |
| 38 | +function loadMarkDownScript(callback) { |
| 39 | + load_marked_script( |
| 40 | + function () { |
| 41 | + load_highlight_stylesheet(); |
| 42 | + load_highlight_script(callback); |
| 43 | + } |
| 44 | + ); |
| 45 | +} |
| 46 | + |
23 | 47 | function renderMarkdwon(markdownViewId, markdownFileURL) { |
24 | 48 | var xmlhttp = new XMLHttpRequest(); |
25 | 49 | xmlhttp.onreadystatechange = |
|
0 commit comments