File tree Expand file tree Collapse file tree 2 files changed +62
-0
lines changed
Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 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 ) {
Original file line number Diff line number Diff line change 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 ) {
You can’t perform that action at this time.
0 commit comments