Class/Module Index [+]

Quicksearch

HTML5::XHTMLParser

liberal XMTHML parser

Public Class Methods

new(options = {}) click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/liberalxmlparser.rb, line 71
def initialize(options = {})
  super options
  @phases[:initial] = InitialPhase.new(self, @tree)
  @phases[:rootElement] = XhmlRootPhase.new(self, @tree)
end

Public Instance Methods

normalize_token(token) click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/liberalxmlparser.rb, line 77
def normalize_token(token)
  super(token)

  # ensure that non-void XHTML elements have content so that separate
  # open and close tags are emitted
  if token[:type]  == :EndTag
    if VOID_ELEMENTS.include? token[:name]
      if @tree.open_elements[-1].name != token["name"]
        token[:type] = :EmptyTag
        token["data"] ||= {}
      end
    else
      if token[:name] == @tree.open_elements[-1].name and              not @tree.open_elements[-1].hasContent
        @tree.insertText('') unless
          @tree.open_elements.any? {|e|
            e.attributes.keys.include? 'xmlns' and
            e.attributes['xmlns'] != 'http://www.w3.org/1999/xhtml'
          }
       end
    end
  end

  return token
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.