File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414
1515class EvalDoc < Kramdown ::Document
1616 attr_accessor :context , :stdout
17+ attr_reader :javascripts
1718
1819 def initialize ( text , *opts )
1920 super ( text , *opts )
2021
22+ @javascripts = { }
2123 self . context = get_context
2224 self . root = scan_el ( self . root )
2325 end
2426
27+ REQUIREJS_SCRIPT_TAG = '<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>'
28+
2529 private
2630 def scan_el ( el )
2731 new_children = [ ]
@@ -34,6 +38,7 @@ class EvalDoc < Kramdown::Document
3438 if is_code && child_el . options [ :lang ] == 'ruby'
3539 code = child_el . value . gsub ( /^ *ruby *\n / , '' )
3640 new_children << eval_and_elementize ( code )
41+ @javascripts [ :requirejs ] ||= REQUIREJS_SCRIPT_TAG
3742 end
3843 end
3944
Original file line number Diff line number Diff line change 1616 display : none;
1717 }
1818 </ style >
19- < script src =" https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js " > </ script >
19+ <%= doc . javascripts . values . join ( '' ) % >
2020 </ head >
2121 < body >
2222 < article class ='markdown-body '>
You can’t perform that action at this time.
0 commit comments