File tree Expand file tree Collapse file tree 3 files changed +49
-8
lines changed Expand file tree Collapse file tree 3 files changed +49
-8
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,11 @@ const EasyCoder_Showdown = {
21
21
run : program => {
22
22
const command = program [ program . pc ] ;
23
23
if ( typeof showdown === `undefined` ) {
24
- program . require ( `js` , `https://unpkg.com/showdown@1.9.1/./dist/showdown.js` , function ( ) {
25
- EasyCoder_Showdown . setupExtension ( ) ;
26
- program . run ( command . pc + 1 ) ;
27
- } ) ;
24
+ program . require ( `js` , `https://cdn.rawgit.com/showdownjs/showdown/1.9.1/dist/showdown.min.js` ,
25
+ ( ) => {
26
+ EasyCoder_Showdown . setupExtension ( ) ;
27
+ program . run ( command . pc + 1 ) ;
28
+ } ) ;
28
29
}
29
30
else {
30
31
EasyCoder_Showdown . setupExtension ( ) ;
Original file line number Diff line number Diff line change @@ -569,6 +569,44 @@ const IWSY = (container, text) => {
569
569
initScript ( ) ;
570
570
} ;
571
571
572
+ // Set up Showdown
573
+ const setupShowdown = ( ) => {
574
+ if ( typeof showdown === `undefined` ) {
575
+ require ( `js` , `https://cdn.rawgit.com/showdownjs/showdown/1.9.1/dist/showdown.min.js` ,
576
+ ( ) => {
577
+ } ) ;
578
+ }
579
+ else {
580
+ }
581
+ } ;
582
+
583
+ // Load a JS or CSS library
584
+ const require = ( type , src , cb ) => {
585
+ let prefix = `` ;
586
+ if ( src [ 0 ] == `/` ) {
587
+ prefix = window . location + `/` ;
588
+ }
589
+ const element = document . createElement ( type === `css` ? `link` : `script` ) ;
590
+ switch ( type ) {
591
+ case `css` :
592
+ element . type = `text/css` ;
593
+ element . href = `${ prefix } ${ src } ` ;
594
+ element . rel = `stylesheet` ;
595
+ break ;
596
+ case `js` :
597
+ element . type = `text/javascript` ;
598
+ element . src = `${ prefix } ${ src } ` ;
599
+ break ;
600
+ default :
601
+ return ;
602
+ }
603
+ element . onload = function ( ) {
604
+ console . log ( `Library ${ prefix } ${ src } loaded` ) ;
605
+ cb ( ) ;
606
+ } ;
607
+ document . head . appendChild ( element ) ;
608
+ } ,
609
+
572
610
// Initialize the script
573
611
const initScript = ( ) => {
574
612
document . onkeydown = null ;
@@ -670,6 +708,7 @@ const IWSY = (container, text) => {
670
708
if ( script . runMode === `auto` ) {
671
709
document . addEventListener ( `click` , onClick ) ;
672
710
}
711
+ setupShowdown ( ) ;
673
712
initScript ( ) ;
674
713
IWSY . plugins = { } ;
675
714
preloadImages ( ) ;
Original file line number Diff line number Diff line change @@ -21,10 +21,11 @@ const EasyCoder_Showdown = {
21
21
run : program => {
22
22
const command = program [ program . pc ] ;
23
23
if ( typeof showdown === `undefined` ) {
24
- program . require ( `js` , `https://unpkg.com/showdown@1.9.1/./dist/showdown.js` , function ( ) {
25
- EasyCoder_Showdown . setupExtension ( ) ;
26
- program . run ( command . pc + 1 ) ;
27
- } ) ;
24
+ program . require ( `js` , `https://cdn.rawgit.com/showdownjs/showdown/1.9.1/dist/showdown.min.js` ,
25
+ ( ) => {
26
+ EasyCoder_Showdown . setupExtension ( ) ;
27
+ program . run ( command . pc + 1 ) ;
28
+ } ) ;
28
29
}
29
30
else {
30
31
EasyCoder_Showdown . setupExtension ( ) ;
You can’t perform that action at this time.
0 commit comments