https://github.com/inversoft/prime-transformer
Fast Java8 BBCode & HTML parser and transformation library.
https://github.com/inversoft/prime-transformer
bbcode bbcode-parser html-parser java8
Last synced: 10 months ago
JSON representation
Fast Java8 BBCode & HTML parser and transformation library.
- Host: GitHub
- URL: https://github.com/inversoft/prime-transformer
- Owner: inversoft
- License: apache-2.0
- Created: 2014-05-20T19:31:43.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-04-15T19:43:11.000Z (almost 3 years ago)
- Last Synced: 2024-04-08T17:19:02.657Z (almost 2 years ago)
- Topics: bbcode, bbcode-parser, html-parser, java8
- Language: Java
- Homepage: http://www.inversoft.org
- Size: 499 KB
- Stars: 14
- Watchers: 15
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Prime Transformer 
Prime Transformer is a BBCode parser and transformation library. Additional implementations may be added support additional source or target markup languages.
The parser returns a light weight document object model of the source BBCode consisting mostly of index values and offsets that can be utilized by the transformer.
Prime Transformer is actively developed and is being utilized in high performance commercial products.
##### Example:
```java
String source = "[b]Hello World![/b]";
Document document = new BBCodeParser().buildDocument(source, null);
String html = new BBCodeToHTMLTransformer().transform(document, (node) -> {
// transform predicate, returning false will cause this node to not be transformed
return true;
}, new HTMLTransformFunction(), null);
Assert.assertEquals(html, "Hello World!");
```
In the above example, we also provided a transform function as the third parameter. This parameter is optional, but most users will wish to escape HTML characters.
This function is provided in the library, the caller can provide their own implementation as well.
##### Features:
* Written in Java 8
* No regular expressions, implementation uses a finite state machine... it's fast
* Supports tag attributes
* Tag does not require a closing tag. (e.g. [*])
* Tag has a pre-formatted body (e.g. [code] or [noparse])
* Supports escape character.
* Normal: ```[b]foo\[/b]``` --> **foo**
* Escaped: ```\[b]foo\[/b]``` --> ```[b]foo[/b]```
### Download from Maven
```xml
com.inversoft
prime-transformer
2.1.4
```
### Building in Maven
```bash
$ mvn install
```
### Downloading from Savant
Released versions can be downloaded from the Savant Repository.
* http://savant.inversoft.org/org/primeframework/prime-transformer/
### Building in Savant
**Note:** This project uses the Savant build tool. To compile using using Savant, follow these instructions:
```bash
$ mkdir ~/savant
$ cd ~/savant
$ wget http://savant.inversoft.org/org/savantbuild/savant-core/1.0.0/savant-1.0.0.tar.gz
$ tar xvfz savant-1.0.0.tar.gz
$ ln -s ./savant-1.0.0 current
$ export PATH=$PATH:~/savant/current/bin/
```
Then, perform an integration build of the project by running:
```bash
$ sb int
```
For more information, checkout [savantbuild.org](http://savantbuild.org/).