Class HTML5::XHTMLParser
In: lib/feed_tools/vendor/html5/lib/html5/liberalxmlparser.rb
Parent: XMLParser

liberal XMTHML parser

Methods

Public Class methods

[Source]

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

Public Instance methods

[Source]

     # File lib/feed_tools/vendor/html5/lib/html5/liberalxmlparser.rb, line 77
 77:     def normalize_token(token)
 78:       super(token)
 79: 
 80:       # ensure that non-void XHTML elements have content so that separate
 81:       # open and close tags are emitted
 82:       if token[:type]  == :EndTag
 83:         if VOID_ELEMENTS.include? token[:name]
 84:           if @tree.open_elements[-1].name != token["name"]
 85:             token[:type] = :EmptyTag
 86:             token["data"] ||= {}
 87:           end
 88:         else
 89:           if token[:name] == @tree.open_elements[-1].name and \
 90:             not @tree.open_elements[-1].hasContent
 91:             @tree.insertText('') unless
 92:               @tree.open_elements.any? {|e|
 93:                 e.attributes.keys.include? 'xmlns' and
 94:                 e.attributes['xmlns'] != 'http://www.w3.org/1999/xhtml'
 95:               }
 96:            end
 97:         end
 98:       end
 99: 
100:       return token
101:     end

[Validate]