class Nori::Parser::Nokogiri::Document
Attributes
options[RW]
Public Instance Methods
characters(string)
click to toggle source
If this node is a successive character then add it as is. First child being a space-only text node will not be added because there is no previous characters.
# File lib/nori/parser/nokogiri.rb, line 38 def characters(string) last = stack.last if last and last.children.last.is_a?(String) or string.strip.size > 0 last.add_node(string) end end
Also aliased as: cdata_block
end_element(name)
click to toggle source
To keep backward behaviour compatibility delete last child if it is a space-only text node
# File lib/nori/parser/nokogiri.rb, line 24 def end_element(name) if stack.size > 1 last = stack.pop maybe_string = last.children.last if maybe_string.is_a?(String) and maybe_string.strip.empty? last.children.pop end stack.last.add_node last end end
stack()
click to toggle source
# File lib/nori/parser/nokogiri.rb, line 14 def stack @stack ||= [] end
start_element(name, attrs = [])
click to toggle source
# File lib/nori/parser/nokogiri.rb, line 18 def start_element(name, attrs = []) stack.push Nori::XMLUtilityNode.new(options, name, Hash[*attrs.flatten]) end