html frontend works
[augment.git] / lib / frontends / html_frontend.rb
blob0e9d9acde03ac4115b27c8e482a73d497d4e06bc
1 class String
2   def html_colorize(color)
3     "<span style='color: #{color};'>#{self}</span>"
4   end
6   def html_colorize_range(range, color)
7     "#{self[0 ... range.begin]}#{self[range].html_colorize(color)}#{self[range.end .. -1]}"
8   end
9 end
11 class HtmlFrontend < Frontend
12   class << self
13     def show(file)
14       puts "<html>
15   <head><title>#{file} - Augment</title></head>
16   <body>
17 #{super(file).gsub("\n", "<br />")}
18   </body>
19 </html>"
20     end
21     
22     def process_layer(text, layer)
23       text.html_colorize_range(layer['range'], layer['color'])
24     end
25   end
26 end
28 Augment::FRONTENDS['html'] = HtmlFrontend