class Mustermann::Visualizer::Renderer::HTML

Generates HTML output. @!visibility private

Public Class Methods

new(target, tag: :span, class_prefix: "mustermann_", css: :inline, **options) click to toggle source

@!visibility private

# File lib/mustermann/visualizer/renderer/html.rb, line 13
def initialize(target, tag: :span, class_prefix: "mustermann_", css: :inline, **options)
  raise ArgumentError, 'css option %p not supported, should be true, false or inline' if css != true and css != false and css != :inline
  super(target, **options)
  @css, @tag, @class_prefix = css, tag, class_prefix
end

Public Instance Methods

escape_string(string) click to toggle source

@!visibility private

# File lib/mustermann/visualizer/renderer/html.rb, line 30
def escape_string(string)
  CGI.escape_html(string)
end
post(type) click to toggle source

@!visibility private

# File lib/mustermann/visualizer/renderer/html.rb, line 45
def post(type)
  "</#{@tag}>"
end
pre(type) click to toggle source

@!visibility private

# File lib/mustermann/visualizer/renderer/html.rb, line 35
def pre(type)
  if @css == :inline
    return "" unless rule = @target.theme[type]
    "<#{@tag} style=\"#{rule.to_css_rule}\">"
  else
    "<#{@tag} class=\"#{@class_prefix}#{type}\">"
  end
end
preamble() click to toggle source

@!visibility private

# File lib/mustermann/visualizer/renderer/html.rb, line 20
def preamble
  "<style type=\"text/css\">\n%s</style>" %  stylesheet if  @css == true
end
stylesheet() click to toggle source

@!visibility private

# File lib/mustermann/visualizer/renderer/html.rb, line 25
def stylesheet
  @target.theme.to_css { |name| ".#{@class_prefix}pattern .#{@class_prefix}#{name}" }
end