Skip to content

Commit 27f7b45

Browse files
committed
1
1 parent 4bbd67c commit 27f7b45

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

web/page-git/page1.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,37 @@
3232
</div>
3333

3434
<script>
35+
function loadMarkDownScript(callback) {
36+
var script = document.createElement('script');
37+
script.src = "https://cdn.jsdelivr.net/npm/showdown/dist/showdown.min.js";
38+
//script.src = "https://cdn.jsdelivr.net/npm/marked/marked.min.js";
39+
script.type = "text/javascript";
40+
script.onload = callback;
41+
document.head.appendChild(script);
42+
}
43+
44+
function renderMarkdwon(markdown_view_id, markdown_url) {
45+
var xmlhttp = new XMLHttpRequest();
46+
xmlhttp.onreadystatechange =
47+
function () {
48+
if (this.readyState == 4 && this.status == 200) {
49+
const markdown = this.responseText;
50+
51+
//marked
52+
//const html = marked.parse(markdown);
53+
54+
//showdown
55+
const converter = new showdown.Converter();
56+
const html = converter.makeHtml(markdown);
57+
58+
document.getElementById(markdown_view_id).innerHTML = html;
59+
}
60+
}
61+
;
62+
xmlhttp.open("GET", markdown_url, true);
63+
xmlhttp.send();
64+
}
65+
3566
function initializeMarkdwonView() {
3667
const view = document.getElementById("page-markdown-view");
3768
if (!view) {

web/page-git/page2.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,37 @@
3232
</div>
3333

3434
<script>
35+
function loadMarkDownScript(callback) {
36+
var script = document.createElement('script');
37+
script.src = "https://cdn.jsdelivr.net/npm/showdown/dist/showdown.min.js";
38+
//script.src = "https://cdn.jsdelivr.net/npm/marked/marked.min.js";
39+
script.type = "text/javascript";
40+
script.onload = callback;
41+
document.head.appendChild(script);
42+
}
43+
44+
function renderMarkdwon(markdown_view_id, markdown_url) {
45+
var xmlhttp = new XMLHttpRequest();
46+
xmlhttp.onreadystatechange =
47+
function () {
48+
if (this.readyState == 4 && this.status == 200) {
49+
const markdown = this.responseText;
50+
51+
//marked
52+
//const html = marked.parse(markdown);
53+
54+
//showdown
55+
const converter = new showdown.Converter();
56+
const html = converter.makeHtml(markdown);
57+
58+
document.getElementById(markdown_view_id).innerHTML = html;
59+
}
60+
}
61+
;
62+
xmlhttp.open("GET", markdown_url, true);
63+
xmlhttp.send();
64+
}
65+
3566
function initializeMarkdwonView() {
3667
const view = document.getElementById("page-markdown-view");
3768
if (!view) {

0 commit comments

Comments
 (0)