Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close
html2text.rb	Ruby conversion from HTML to TEXT

Chip Camden	May, 2011

I required this function for my Feed-to-Email utility, feedmbox
(http://bitbucket.org/sterlingcamden/feedmbox).  The Unix utility
html2text didn't provide everything I need.  It destroys all
embedded links, and I wanted those footnoted to their URLs.

This version is based on a function published by Choon Keat here:
http://blog.choonkeat.com/weblog/2005/10/html2text-funct.html
Chew's version needed a few adjustments, the most recent of which
is to honor <pre> tags.

You can run this as a command line script, and it will translate
stdin or file arguments to standard out.  Or you can require the
file in your project and call the "html2text" function, passing
it the HTML and it will return the text.

END

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.