I am trying to replace a <blockquote>
tag with text in an HTMl document. I started off using Nokogiri to do this. The problem is the HTML I pass to Nokogiri contains text like <my_mail@gmail.com>
which nokogiri considers as a tag. The output is all screwed because Nokogiri tries to correct the "tag" by adding </my_mail>
to the html doc.
Any ideas how to turn off this auto correction in Nokogiri or are there any other gems I can use to do this without screwing the output?
You can escape <
and >
around mail before sending string to Nokogiri.
>> "<html><body><my_mail@gmail.com></body></html>".gsub(/<([^<]+@[^>]+)>/,'<\1>')
=> "<html><body><my_mail@gmail.com></body></html>"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.