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 =
{ '&' => '&', '<' => '<', '>' => '>', }.freeze
- ESCAPE_REGEX =
/[&<>]/.freeze
Constants inherited from Rouge::Formatter
Instance Method Summary collapse
Methods inherited from Rouge::Formatter
disable_escape!, enable_escape!, #escape?, escape_enabled?, #filter_escapes, find, format, #format, #initialize, #render, tag, with_escape
Constructor Details
This class inherits a constructor from Rouge::Formatter
Instance Method Details
#safe_span(tok, safe_val) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/rouge/formatters/html.rb', line 29 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
23 24 25 26 27 |
# File 'lib/rouge/formatters/html.rb', line 23 def span(tok, val) return val if escape?(tok) safe_span(tok, escape_special_html_chars(val)) end |
#stream(tokens) { ... } ⇒ Object
19 20 21 |
# File 'lib/rouge/formatters/html.rb', line 19 def stream(tokens, &b) tokens.each { |tok, val| yield span(tok, val) } end |