velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominik Bruhn <>
Subject BBCode Parser
Date Sat, 15 Apr 2006 00:15:31 GMT
I know its not a velocity-specific question, but perhaps someone knows a 

Perhaps you know BBCode: These is a Markup-Language used in 
Web-Bulletin-Boards like PHPBB or VBulletin. BB-Codes makes it possible to 
format the text by the user in easy ways while perserving the security for 
the administrators (no JavaScript, no IFrames, only permitted Tags). For 
example you get the String "[b]This is Bold [i] and this is italic and 
bold[/i][/b]". Now I need a piece of java which converts these Strings into 
HTML again, in case of this example to a string like "<b>This is Bold <i> and

this is italic </i></b>". There are some difficult tags like 
[url=""]Search Engine[/url] which should be converted to "<a 
href="" target="_blank">Search Engine</a>".

I know you could realize this easily by using Regular-Expressions, but this is 
not enough: You have to check that every tag opened is closed again, 
otherwise you get ugly HTML or the User is able to format more than his code 
because there is no closing Tag.

I know the solution for these problems is to split up the string into a tree, 
then check it and merge the tree to the output-string again. Thats how the 
mentioned PHP-Boards do it. I could now realize this code in Java which costs 
me many time. Thats why I ask here: Is there someone who knows a 
BBCode-Parser written in Java?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message