I have this code:
我有这个代码:
# encoding: utf-8
require 'nokogiri'
s = "<a href='/go.html?url=/path/to/file'>Café Verona</a>".encode('UTF-8')
puts "Original string: #{s}"
@doc = Nokogiri::HTML::DocumentFragment.parse(s)
links = @doc.css('a')
only_text = 'Café Verona'.encode('UTF-8')
puts "Replacement text: #{only_text}"
links.first.replace(only_text)
puts @doc.to_html
# encoding: utf-8