class Rouge::Formatters::HTML
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/rouge/formatters/html.rbs class Rouge::Formatters::HTML < Rouge::Formatters::Formatter def escape_special_html_chars: (String value) -> String def safe_span: (Class tok, String safe_val) -> String def span: (Class tok, String val) -> String def stream: (Enumerator tokens, ) -> String end
Transforms a token stream into HTML output.
def escape_special_html_chars(value)
Experimental RBS support (using type sampling data from the type_fusion
project).
def escape_special_html_chars: (String value) -> String
This signature was generated using 109 samples from 2 applications.
Returns either the given `value` argument string as is or a new string with the
a substitution is imminent.
a substitution occurs. This method however invokes `String#gsub` only if
`String#gsub` will always return a new string instance irrespective of whether
HTML from this formatter.
A performance-oriented helper method to escape `&`, `<` and `>` for the rendered
def escape_special_html_chars(value) return value unless value =~ ESCAPE_REGEX value.gsub(ESCAPE_REGEX, TABLE_FOR_ESCAPE_HTML) end
def safe_span(tok, safe_val)
Experimental RBS support (using type sampling data from the type_fusion
project).
def safe_span: (Class tok, String safe_val) -> String
This signature was generated using 105 samples from 2 applications.
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
def span(tok, val)
Experimental RBS support (using type sampling data from the type_fusion
project).
def span: (Class tok, String val) -> String
This signature was generated using 102 samples from 2 applications.
def span(tok, val) return val if escape?(tok) safe_span(tok, escape_special_html_chars(val)) end
def stream(tokens, &b)
Experimental RBS support (using type sampling data from the type_fusion
project).
def stream: (Enumerator tokens, ) -> String
This signature was generated using 2 samples from 1 application.
- Yield: - the html output.
def stream(tokens, &b) tokens.each { |tok, val| yield span(tok, val) } end