implemented flog backend
[augment.git] / lib / frontends / html_frontend.rb
blob33752c83ea31ceafd8631706f1afc2a08ce9b1bf
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 run(file)
14       puts "<html>
15   <head><title>#{file} - Augment</title></head>
16   <body>
17 #{super(file).gsub("\n", "<br />").gsub('  ', '&nbsp; ')}
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   Augment::FRONTENDS['html'] = self
27 end