21 May 2002 barryp   » (Journeyer)

effbot: Nice, but your attributes need to be double-quoted instead of single-quoted. How about:
def mktag(tag, data, **attrs):
    tag = tag.lower()
    attrs = "".join([' %s="%s"' % (k.lower(), v) for k, v in
attrs.items()])
    if data:
        return "<%s%s>%s</%s>" % (tag, attrs,
data, tag)
    else:
        return "<%s%s />" % (tag, attrs)

for tag in ("a", "ul", "li", "img"): # etc exec "%s = lambda d=None, **a: mktag(%r, d, **a)" % (tag, tag)

if __name__ == '__main__': print a("Google", href="http://www.google.com") print ul(li("item1") + li("item2") + li("item3")) print img(src="foo.jpg")

More XHTML-compliant (lowercase tags, empty tags) Too bad there's no easy way to HTML-escape data strings, but not the tags that are generated.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!