class Glimmer::XML::HtmlVisitor

Public Instance Methods

append_attributes(node) click to toggle source
Calls superclass method
# File lib/glimmer/xml/html_visitor.rb, line 55
def append_attributes(node)
  return unless render_html_tag?(node)
  super(node)
end
append_close_tag(node) click to toggle source
Calls superclass method
# File lib/glimmer/xml/html_visitor.rb, line 50
def append_close_tag(node)
  return unless render_html_tag?(node)
  super(node)
end
begin_open_tag(node) click to toggle source
Calls superclass method
# File lib/glimmer/xml/html_visitor.rb, line 39
def begin_open_tag(node)
  return unless render_html_tag?(node)
  @document += "<!DOCTYPE html>" if node.name == 'html'
  super(node)
end
end_open_tag(node) click to toggle source
Calls superclass method
# File lib/glimmer/xml/html_visitor.rb, line 45
def end_open_tag(node)
  return unless render_html_tag?(node)
  super(node)
end
render_html_tag?(node) click to toggle source
# File lib/glimmer/xml/html_visitor.rb, line 28
def render_html_tag?(node)
  if node.name == 'html'
    node_children = node.children.select {|node_or_text| node_or_text.is_a?(Glimmer::XML::Node)}
    if !node_children.empty?
      children_names = node_children.map(&:name)
      return false unless children_names.include?('head') || children_names.include?('body')
    end
  end
  true
end