Class: Rouge::Formatters::HTML
- Inherits:
-
Rouge::Formatter
- Object
- Rouge::Formatter
- Rouge::Formatters::HTML
- Defined in:
- lib/rouge/formatters/html.rb
Overview
Transforms a token stream into HTML output.
Direct Known Subclasses
Constant Summary collapse
- TABLE_FOR_ESCAPE_HTML =
{ '&' => '&', '<' => '<', '>' => '>', }
Instance Method Summary collapse
Methods inherited from Rouge::Formatter
disable_escape!, enable_escape!, #escape?, escape_enabled?, #filter_escapes, find, format, #format, #initialize, #render, tag, #token_lines, with_escape
Constructor Details
This class inherits a constructor from Rouge::Formatter
Instance Method Details
#safe_span(tok, safe_val) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rouge/formatters/html.rb', line 21 def safe_span(tok, safe_val) if tok == Token::Tokens::Text safe_val else shortname = tok.shortname \ or raise "unknown token: #{tok.inspect} for #{safe_val.inspect}" "<span class=\"#{shortname}\">#{safe_val}</span>" end end |
#span(tok, val) ⇒ Object
15 16 17 18 19 |
# File 'lib/rouge/formatters/html.rb', line 15 def span(tok, val) return val if escape?(tok) safe_span(tok, escape_special_html_chars(val)) end |
#stream(tokens) { ... } ⇒ Object
11 12 13 |
# File 'lib/rouge/formatters/html.rb', line 11 def stream(tokens, &b) tokens.each { |tok, val| yield span(tok, val) } end |