Skip to content

Latest commit

 

History

History
83 lines (65 loc) · 3.85 KB

README.md

File metadata and controls

83 lines (65 loc) · 3.85 KB

KefirBB

Build Status Download Maven Central javadoc.io OpenHUB

About

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.

Maven dependency

<dependency>
    <groupId>org.kefirsf</groupId>
    <artifactId>kefirbb</artifactId>
    <version>1.5</version>
</dependency>

Usage

Convert BBCode

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]"));

HTML Filtration

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>"));

Convert Textile

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**"));

Convert Markdown

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**"));

Your custom configuration

Also you can use your own configuration or customize existing. Just put your own configuration to classpath:kefirbb.xml.

Documentation

You can find full documentation in the wiki of the project.

Support

You can report bugs at GitHub Issues. Also you can ask me questions by email [email protected].

Donation

If you want to give me a beer just send some money to https://www.paypal.me/kefir