Has anybody used a good Java implementation of BBCode? I am looking at
- javabbcode : nothing to see
- kefir-bb : Listed as alpha
- BBcode parser in JBoss source code.
Are there any better options?
Has anybody used a good Java implementation of BBCode? I am looking at
Are there any better options?
The current version of KefirBB 0.6 is not listed as beta anymore. I find the KefirBB parser very easy to configure and extend with my own tags:
kefir-bb.sourceforge.net
(This is the best BBCode parser I've found so far)
I also found this code at fyhao.com, but it does protect you against incorrectly nested tags (thus not suitable for parsing user entered input):
BTW javaBBcode is part of opensource project: JavaBB.
Unless you have non technical users who are used to bbcode and aren't terribly interested in learning another arcane markup format.
I have successfully used regular expressions in the past to flip between html and bbcode. Define a list of expressions that cover each tag, and precompile the Patterns for each one. Then iteratively transform the string with each expression. Works both ways. Performance is actually pretty good, and you can adapt to your own dialect/extensions easily.
Downside is that regex aren't always straightforward to work out.
I believe a better option is to use wiki markup. You can try the Mylyn Wikitext package which I currently use with great success for our Documentation system.
However, this is not an answer to your problem, if what you try is to parse some forum text you already have automatically :-I
Another Java option for BBCode parsing and transforming to HTML is Prime Transformer.
https://github.com/inversoft/prime-transformer
We built this for some specific uses but tried to keep it generic enough for general consumption. I've got a basic example of how to put it together on the landing page on GitHub.