Class: Nokogiri::XML::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/html/pipeline.rb

Overview

XXX nokogiri monkey patches

Instance Method Summary collapse

Instance Method Details

#replace_with_encoding_fix(replacement) ⇒ Object Also known as: replace

Work around an issue with utf-8 encoded data being erroneously converted to … some other shit when replacing text nodes. See ‘utf-8 output 2’ in user_content_test.rb for details.



116
117
118
119
120
121
# File 'lib/html/pipeline.rb', line 116

def replace_with_encoding_fix(replacement)
  if replacement.respond_to?(:to_str)
    replacement = document.fragment("<div>#{replacement}</div>").children.first.children
  end
  replace_without_encoding_fix(replacement)
end

#swap(replacement) ⇒ Object



126
127
128
129
# File 'lib/html/pipeline.rb', line 126

def swap(replacement)
  replace(replacement)
  self
end