3
3
require 'hexp/h'
4
4
5
5
class ImpressRenderer < Redcarpet ::Render ::HTML
6
+ attr_accessor :dest
7
+
6
8
@attrs = [ ]
7
9
@current = 0
8
10
@author , @head , @title = nil
@@ -27,6 +29,7 @@ def title= title
27
29
end
28
30
29
31
def render_attrs ( hsh )
32
+ "class='step #{ hsh . delete ( 'class' ) } ' " +
30
33
hsh . map do |k , v |
31
34
if v =~ /([\+ \- ])(\d +)/
32
35
@counters [ k ] ||= 0
@@ -46,7 +49,7 @@ def hrule
46
49
# this is how we later inject attributes into pages. what an awful hack.
47
50
@current += 1
48
51
%{</div>
49
- <div class='step' #{ render_attrs ( @attrs [ @current ] ) } >
52
+ <div #{ render_attrs ( @attrs [ @current ] ) } >
50
53
}
51
54
end
52
55
@@ -72,6 +75,13 @@ def codespan code
72
75
H [ :code , { class : "inline prettyprint" } , code ] . to_html
73
76
end
74
77
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
+
75
85
def mathjax
76
86
if @opts [ :latex ]
77
87
%{
@@ -112,7 +122,7 @@ def doc_header
112
122
<p>For the best experience please use the latest <b>Chrome</b>, <b>Safari</b> or <b>Firefox</b> browser.</p>
113
123
</div>
114
124
<div id="impress">
115
- <div class='step' #{ render_attrs ( @attrs [ 0 ] ) } >
125
+ <div #{ render_attrs ( @attrs [ 0 ] ) } >
116
126
}
117
127
end
118
128
0 commit comments