A better remove_html?

Has anyone done a smart replacement for Movable Type’s remove_html function? There aren’t very many people I read who still only stick an auto-generated excerpt or an HTML-free version of their posts in their RSS, but there are a few, and I’d like to be able to recommend something slightly less evil to them.

For instance, Meg’s cleanup post, featuring an unordered list written in the style common to many of us who’ve suffered through fairly dim autoparagraphing code, doesn’t have any whitespace, just markup separating the items, so in my aggregator I get

A recipe for Pickled Oysters with English Cucumber “Capellini” and DillA map of the Madaket (Nantucket) bus routeVarious torrents of things I never listened to, like Jon Stewart’s Crossfire appearanceMore strange .pdf files that I must have inadvertantly downloaded than I care to admitAn Excel spreadsheet from 4/2003 comparing the costs of purcasing an espresso machine to going to the local coffee shop to making due with my French Press pot at homeMy brother’s “updated” résumé from early 2004

Given all the lovely filters like Markdown and whatnot that will take plain text and turn it into nice HTML, it seems like we ought to have one that would do the reverse, but I’d settle for one that just knows enough to ensure there’s some form of whitespace in places where the HTML would guarantee a break. (Yes, I do realize exactly what it means that I’m not willing to fix it myself. But, hey! This ain’t open source: I’m supposed to bitch instead of fixing!)

4 Comments

Comment by Ben Tucker #
2005-02-17 21:10:23

Aaron’s html2text isn’t bad. And as an added bonus the output is valid Markdown.

Comment by Phil Ringnalda #
2005-02-17 21:21:58

And porting Python to Perl only makes you bang your head against the keyboard, unlike Python to PHP, which makes you wail, rend your garments, and pull big chunks of hair and scalp off your head.

Comment by Ben Tucker #
2005-02-18 07:11:46

Indeed. :) I ended up just wrapping it in a perl module using Inline::Python.

 
 
 
Comment by Andrew Green #
2005-02-18 01:21:22

I have no idea how easy it would be to integrate with Movable Type, but a while back I released an XSLT stylesheet that transforms XHTML into Markdown.

 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <del datetime="" cite=""> <dd> <dl> <dt> <em> <i> <ins datetime="" cite=""> <kbd> <li> <ol> <p> <pre> <q cite=""> <samp> <strong> <sub> <sup> <ul> in your comment.