Archives

February 2010 (1)
September 2009 (1)
May 2009 (1)
April 2009 (1)
March 2009 (4)
January 2009 (3)

November 2008 (2)
October 2008 (2)
September 2008 (1)
August 2008 (5)
July 2008 (3)
June 2008 (1)
May 2008 (5)
April 2008 (8)
March 2008 (3)
February 2008 (1)
January 2008 (2)

December 2007 (2)
November 2007 (4)
October 2007 (17)
September 2007 (9)

Elements or attributes, the eternal question

Sunday, May 10 2009

Nice take on when to use attributes in XML here.

no comments

Tags: xml ~ linky

Shelly Powers: the Parable of the Languages

Thursday, October 11 2007

I love the ending.

no comments

Tags: programming ~ xml ~ linky ~ funny

HTMLTidy for Python

Friday, September 28 2007

When importing all my old content, I hit a snag. A lot of vital.org.nz has pretty broken markup in it. Burble’s templating system is strict XML under the hood, so any post or comment that contains broken markup causes burble to barf.

I discovered that there is a lovely Python wrapper for HTML Tidy. And there’s even an Ubuntu package. Problem solved.

>>> import tidy
>>> html = 'some <b>horrible<i> soup</b> which is nasty & yukky'
>>> options = {'show-body-only':'y', 'output-xhtml':'y', 'enclose-block-text':'y', 'enclose-text':'y'}
>>> body = str(tidy.parseString(html, **options))
>>> body
'<p>some <b>horrible <i>soup</i> which is nasty &amp; yukky</b></p>\n\n'

no comments

Tags: burble ~ python ~ html tidy ~ xml

Recent comments

Rendered at 2010-03-14 17:56:05