Skip to content

Instantly share code, notes, and snippets.

@dannguyen
Created February 14, 2014 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannguyen/8986870 to your computer and use it in GitHub Desktop.
Save dannguyen/8986870 to your computer and use it in GitHub Desktop.
How to use the Loofah library with a Nokogiri node to preserve line breaks between block elements
npage = Nokogiri::HTML(html)
h[:text] = Loofah.fragment(npage.search('.displaytext').to_html).to_text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment