class Nori::Parser::Nokogiri::Document
Attributes
Public Instance Methods
Source
# 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
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.
Also aliased as: cdata_block
Source
# 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
To keep backward behaviour compatibility delete last child if it is a space-only text node
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