cleanup code and update docs authored by Vladimir Schneider's avatar Vladimir Schneider
......@@ -37,14 +37,16 @@ The values are accessed via the `DataHolder` and `MutableDataHolder` interfaces,
being a read only container. Since the data key provides a unique identifier for the data there
is no collision for options.
To configure the parser or renderer, pass a data holder to the `builder()` method.
To configure the parser or renderer, pass a data holder to the `builder()` method with the
desired options configured, including extensions.
```java
public class SomeClass {
import javax.swing.text.html.parser.Parser;public class SomeClass {
static final MutableDataHolder OPTIONS = new MutableDataSet()
.set(Parser.REFERENCES_KEEP, KeepType.LAST)
.set(HtmlRenderer.INDENT_SIZE, 2)
.set(HtmlRenderer.PERCENT_ENCODE_URLS, true)
.set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create()))
;
static final Parser PARSER = Parser.builder(OPTIONS).build();
......@@ -68,10 +70,18 @@ last.
By convention, data keys are defined in the extension class and in the case of the core in the
`Parser` or `HtmlRenderer`.
Data keys are defined in the following classes:
Data keys are described in their respective extension classes and in `Parser` and `HtmlRenderer`.
### Parser
Unified options handling added which are also used to selectively disable loading of core
parsers and processors.
`Parser.builder()` now implements `MutableDataHolder` so you can use `get`/`set` to customize
properties directly on it or pass it a DataHolder with predefined options.
| Class | Static Field | Default Value | Description |
|--------------|--------------------------------|------------------|---------------------------------------------------------------------------------------|
|--------|--------------------------------|------------------|----------------------------------------------------------------------------------------------------------------------------------|
| Parser | BLOCK_QUOTE_PARSER | `true` | enable parsing of block quotes |
| Parser | HEADING_PARSER | `true` | enable parsing of headings |
| Parser | FENCED_CODE_BLOCK_PARSER | `true` | enable parsing of fenced code blocks |
......@@ -82,25 +92,9 @@ Data keys are defined in the following classes:
| Parser | REFERENCE_BLOCK_PRE_PROCESSOR | `true` | enable parsing of reference definitions |
| Parser | ASTERISK_DELIMITER_PROCESSOR | `true` | enable asterisk delimiter inline processing. |
| Parser | UNDERSCORE_DELIMITER_PROCESSOR | `true` | enable underscore delimiter inline processing. |
| Parser | WIKI_LINKS | `false` | enable wiki link parsing and rendering |
| Parser | WIKI_LINKS_LINK_FIRST | `false` | wiki link with optional text syntax has link first (Creole), default text first (GFM) |
| Parser | REFERENCES | new repository | repository for document's reference definitions |
| Parser | REFERENCES_KEEP | `KeepType.FIRST` | which duplicates to keep. |
| | | | |
| HtmlRenderer | SOFT_BREAK | `"\n"` | string to use for rendering soft breaks |
| HtmlRenderer | ESCAPE_HTML | `false` | escape html found in the document |
| HtmlRenderer | PERCENT_ENCODE_URLS | `false` | percent encode urls |
| HtmlRenderer | INDENT_SIZE | `0` | how many spaces to use for each indent level of nested tags |
| HtmlRenderer | SUPPRESS_HTML_BLOCKS | `false` | suppress html output for html blocks |
| HtmlRenderer | SUPPRESS_INLINE_HTML | `false` | suppress html output for inline html |
### Parser
Unified options handling added which are also used to selectively disable loading of core
parsers and processors.
`Parser.builder()` now implements `MutableDataHolder` so you can use `get`/`set` to customize
properties.
| Parser | EXTENSIONS | empty list | list of extension to use for builders. Can use this option instead of passing extensions to parser builder and renderer builder. |
### Renderer
......@@ -110,10 +104,21 @@ corresponding unified option.
Renderer `Builder()` now has an `indentSize(int)` method to set size of indentation for
hierarchical tags. Same as setting `HtmlRenderer.INDENT_SIZE` data key in options.
| Class | Static Field | Default Value | Description |
|--------------|----------------------|---------------|-------------------------------------------------------------|
| HtmlRenderer | SOFT_BREAK | `"\n"` | string to use for rendering soft breaks |
| HtmlRenderer | ESCAPE_HTML | `false` | escape html found in the document |
| HtmlRenderer | PERCENT_ENCODE_URLS | `false` | percent encode urls |
| HtmlRenderer | INDENT_SIZE | `0` | how many spaces to use for each indent level of nested tags |
| HtmlRenderer | SUPPRESS_HTML_BLOCKS | `false` | suppress html output for html blocks |
| HtmlRenderer | SUPPRESS_INLINE_HTML | `false` | suppress html output for inline html |
## Available Extensions
The following extensions are developed with this library, each in their own artifact.
Extension options are defined in their extension class.
### Autolink
Turns plain links such as URLs and email addresses into links (based on [autolink-java]).
......@@ -130,9 +135,10 @@ Use class `AbbreviationExtension` from artifact `flexmark-ext-abbreviation`.
The following options are available:
| Class | Static Field | Default Value | Description |
|-----------------------|--------------------|------------------|----------------------------------------------------|
|-----------------------|--------------------|------------------|------------------------------------------------------|
| AbbreviationExtension | ABBREVIATIONS | new repository | repository for document's abbreviation definitions |
| AbbreviationExtension | ABBREVIATIONS_KEEP | `KeepType.FIRST` | which duplicates to keep. |
| AbbreviationExtension | USE_LINKS | `false` | use `<a>` instead of `<abb>` tags for rendering html |
### Emoji
......@@ -229,7 +235,7 @@ metadata, use `YamlFrontMatterVisitor`.
[CommonMark]: http://commonmark.org/
[Markdown]: https://daringfireball.net/projects/markdown/
[commonmark.js]: https://github.com/jgm/commonmark.js
[Maven Central]: https://search.maven.org/#search|ga|1|g%3A%22com.atlassian.commonmark%22
[Maven Central]: https://search.maven.org/#search|ga|1|g%3A%22com.vladsch.flexmark%22
[Semantic Versioning]: http://semver.org/
[autolink-java]: https://github.com/robinst/autolink-java
[gfm-tables]: https://help.github.com/articles/organizing-information-with-tables/