33require 'hexp/h'
44
55class ImpressRenderer < Redcarpet ::Render ::HTML
6+ attr_accessor :dest
7+
68 @attrs = [ ]
79 @current = 0
810 @author , @head , @title = nil
@@ -27,6 +29,7 @@ def title= title
2729 end
2830
2931 def render_attrs ( hsh )
32+ "class='step #{ hsh . delete ( 'class' ) } ' " +
3033 hsh . map do |k , v |
3134 if v =~ /([\+ \- ])(\d +)/
3235 @counters [ k ] ||= 0
@@ -46,7 +49,7 @@ def hrule
4649 # this is how we later inject attributes into pages. what an awful hack.
4750 @current += 1
4851 %{</div>
49- <div class='step' #{ render_attrs ( @attrs [ @current ] ) } >
52+ <div #{ render_attrs ( @attrs [ @current ] ) } >
5053 }
5154 end
5255
@@ -72,6 +75,13 @@ def codespan code
7275 H [ :code , { class : "inline prettyprint" } , code ] . to_html
7376 end
7477
78+ def image link , title , alt
79+ if File . exist? ( "images/#{ link } " )
80+ `cp images/#{ link } #{ dest } /#{ link } `
81+ end
82+ H [ :img , { src : link , alt : alt } , title ] . to_html
83+ end
84+
7585 def mathjax
7686 if @opts [ :latex ]
7787 %{
@@ -112,7 +122,7 @@ def doc_header
112122 <p>For the best experience please use the latest <b>Chrome</b>, <b>Safari</b> or <b>Firefox</b> browser.</p>
113123 </div>
114124 <div id="impress">
115- <div class='step' #{ render_attrs ( @attrs [ 0 ] ) } >
125+ <div #{ render_attrs ( @attrs [ 0 ] ) } >
116126 }
117127 end
118128
0 commit comments