KefirBB is a Java-library for text processing. Initially it was developed for BBCode (Bulletin Board Code) to HTML translation. But flexible configuration allows to use it in different cases. For example XML-to-HTML translation or for HTML filtration. Now it supports Textile and Markdown markup languages. Actually it's the most powerfull and flexible Java-library for BBCode parsing.
<dependency>
<groupId>org.kefirsf</groupId>
<artifactId>kefirbb</artifactId>
<version>1.5</version>
</dependency>
KefirBB fully supports converting from BBCode markup language to HTML. The syntax of BBCode is described at BBCode - Wikipedia.
TextProcessor processor = BBProcessorFactory.getInstance().create();
assert "<b>text</b>".equals(processor.process("[b]text[/b]"));
If you don't want to use special markup languages in your site but you have to safe your users from XSS-attacks you can use KefirBB configuration for HTMl filtration. It prevents using of javascript, styles etc.
TextProcessor processor = BBProcessorFactory.getInstance()
.createFromResource(ConfigurationFactory.SAFE_HTML_CONFIGURATION_FILE);
assert "<b>text</b>".equals(processor.process("<b onclick=\"javascript:alert('Fail!');\">test</B>"));
KefirBB fully supports Textile markup language. It's described at TxStyle
TextProcessor processor = BBProcessorFactory.getInstance()
.createFromResource(ConfigurationFactory.TEXTILE_CONFIGURATION_FILE);
assert "<p><b>text</b></p>".equals(processor.process("**text**"));
KefirBB supports Markdown markup language partially described at Markdown Syntax. It doesn't support fully blockquotes and lists.
TextProcessor processor = BBProcessorFactory.getInstance()
.createFromResource(ConfigurationFactory.MARKDOWN_CONFIGURATION_FILE);
assert "<p><strong>text</strong></p>".equals(processor.process("**text**"));
Also you can use your own configuration or customize existing. Just put your own configuration to
classpath:kefirbb.xml
.
You can find full documentation in the wiki of the project.
You can report bugs at GitHub Issues. Also you can ask me questions by email kefirfromperm@gmail.com.
If you want to give me a beer just send some money to https://www.paypal.me/kefir