Is it possible to convert HTML with Nokogiri to plain text? I also want to include tag.
For example, given this HTML:
Instead of writing complex regexp I used Nokogiri.
Working solution (K.I.S.S!):
def strip_html(str) document = Nokogiri::HTML.parse(str) document.css("br").each { |node| node.replace("\n") } document.text end