Python implementation of BBCode?

Terry Hancock hancock at anansispaceworks.com
Tue Dec 3 15:31:09 EST 2002


Hi all,
I'm implementing a Python/Zope/MySQL forum called Narya (there is now a 
mostly-working demo online at http://narya.net , as well as a faq at 
http://www.anansispaceworks.com/NaryaInfo ).

Currently it supports HTML-posting only (e.g. you have to type "<p>" to make 
a paragraph break in a post). This is nice for some purposes, but really 
shouldn't be the default. I plan to implement a structured-text posting 
mechanism using Zope's internal support for ST.

However, many forum users, coming from PHP forums, will be accustomed to 
"BBCode" which is a kind of simplified HTML:

[b]This is bold[/b]

Double-spacing creates a [i]paragraph[/i] in BBCode, and there are
simplified versions of other HTML codes, like [url]http://narya.net[/url]
or a  [url=narya.net]link-style url[/url].

and so on.  So it would be nice to have a BBCode posting option as well.

It's not XML-compatible, as you can see, although it is conceptually similar. 

I did a Google search, but was unable to find any Python implementation (e.g. 
a filter from BBCode to HTML).  So I thought I should ask here. Any ideas?

I could, of course, write one, but I'm not sure about the right approach -- I 
don't think the XML tools can be used on it, so I suppose I'd need to use the 
re module. There's also stripogram, which might be adapted, I suppose.   I'd 
also have to find a definitive spec to write to.

I don't really want to put an inordinate amount of effort into it, because 
there are more important  problems to solve, but it would be nice if an 
implementation existed (or some interested party wanted to write one). 

Thanks for any suggestions,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

"Python takes the pain out of programming ...
            ... and Zope puts it back again."




More information about the Python-list mailing list