Method: EscapeCode::HtmlFormatter#generate
- Defined in:
- lib/escape_code/html_formatter.rb
#generate ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/escape_code/html_formatter.rb', line 14 def generate state = EscapeCode::SgrState.new @scanner.scan.map do |thing| case thing when EscapeCode::Code state.ingest(thing) when String classes = compute_classes(state) if classes.empty? CGI.escapeHTML(thing) else "<span class='#{compute_classes(state)}'>#{CGI.escapeHTML(thing)}</span>" end end end.compact.join end |