Class: Rouge::Formatters::HTMLInline

Inherits:
HTML show all
Defined in:
lib/rouge/formatters/html_inline.rb

Constant Summary

Constants inherited from HTML

Rouge::Formatters::HTML::ESCAPE_REGEX, Rouge::Formatters::HTML::TABLE_FOR_ESCAPE_HTML

Instance Method Summary collapse

Methods inherited from HTML

#span, #stream

Methods inherited from Rouge::Formatter

disable_escape!, enable_escape!, #escape?, escape_enabled?, #filter_escapes, find, #format, format, #render, #stream, tag, #token_lines, with_escape

Constructor Details

#initialize(theme) ⇒ HTMLInline

Returns a new instance of HTMLInline.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rouge/formatters/html_inline.rb', line 9

def initialize(theme)
  if theme.is_a?(Class) && theme < Rouge::Theme
    @theme = theme.new
  elsif theme.is_a?(Rouge::Theme)
    @theme = theme
  elsif theme.is_a?(String)
    @theme = Rouge::Theme.find(theme).new
  else
    raise ArgumentError, "invalid theme: #{theme.inspect}"
  end
end

Instance Method Details

#safe_span(tok, safe_val) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/rouge/formatters/html_inline.rb', line 21

def safe_span(tok, safe_val)
  return safe_val if tok == Token::Tokens::Text

  rules = @theme.style_for(tok).rendered_rules

  "<span style=\"#{rules.to_a.join(';')}\">#{safe_val}</span>"
end