lib/sanitize/transformers/clean_element.rb in sanitize-2.0.0.dev.20101211 vs lib/sanitize/transformers/clean_element.rb in sanitize-2.0.0.dev.20101213

- old
+ new

@@ -32,11 +32,14 @@ # Delete any element that isn't in the config whitelist. unless @allowed_elements[name] # Elements like br, div, p, etc. need to be replaced with whitespace in # order to preserve readability. if @whitespace_elements[name] - node.add_previous_sibling(' ') - node.add_next_sibling(' ') unless node.children.empty? + node.add_previous_sibling(Nokogiri::XML::Text.new(' ', node.document)) + + unless node.children.empty? + node.add_next_sibling(Nokogiri::XML::Text.new(' ', node.document)) + end end unless @remove_all_contents || @remove_element_contents[name] node.children.each {|n| node.add_previous_sibling(n) } end