Skip to content

Commit 2a3876d

Browse files
committed
1
1 parent 31e3429 commit 2a3876d

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

web/markdown.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,39 @@
1111
// https://github.com/markedjs/marked
1212
//===========================================================================
1313

14-
function loadMarkDownScript(callback) {
14+
function load_marked_script(callback) {
1515
var script = document.createElement('script');
1616
//script.src = "https://cdn.jsdelivr.net/npm/marked/marked.min.js";
1717
script.src = "https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.js";
1818
script.type = "text/javascript";
19-
script.onload = callback;
19+
script.onload = callback;
2020
document.head.appendChild(script);
2121
}
2222

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+
2347
function renderMarkdwon(markdownViewId, markdownFileURL) {
2448
var xmlhttp = new XMLHttpRequest();
2549
xmlhttp.onreadystatechange =

0 commit comments

Comments
 (0)