Start with the builder method, configure the parser and build it. Example:
Parser parser = Parser.builder().build();
Node document = parser.parse("input text");
| Modifier and Type | Class and Description |
|---|---|
| public static class | Parser.
Builder for configuring a |
| public static interface | Parser.
Extension for |
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| private final List | |
| private final IncludeSourceSpans | |
| private final InlineParserFactory | |
| private final List |
| Modifier and Type | Method and Description |
|---|---|
| public static Parser. | |
| private DocumentParser | |
| public Node | |
| public Node | Returns: the root nodethe reader to parse - must not be null input)Parse the specified reader into a tree of nodes. |
| private Node |
| blockParserFactories | back to summary |
|---|---|
| private final List<BlockParserFactory> blockParserFactories | |
| delimiterProcessors | back to summary |
|---|---|
| private final List<DelimiterProcessor> delimiterProcessors | |
| includeSourceSpans | back to summary |
|---|---|
| private final IncludeSourceSpans includeSourceSpans | |
| inlineParserFactory | back to summary |
|---|---|
| private final InlineParserFactory inlineParserFactory | |
| postProcessors | back to summary |
|---|---|
| private final List<PostProcessor> postProcessors | |
| Parser | back to summary |
|---|---|
| private Parser(Parser. | |
| builder | back to summary |
|---|---|
| public static Parser. Create a new builder for configuring a | |
| createDocumentParser | back to summary |
|---|---|
| private DocumentParser createDocumentParser() | |
| parse | back to summary |
|---|---|
| public Node parse(String input) Parse the specified input text into a tree of nodes. This method is thread-safe (a new parser state is used for each invocation). | |
| parseReader | back to summary |
|---|---|
| public Node parseReader(Reader input) throws IOException Parse the specified reader into a tree of nodes. The caller is responsible for closing the reader.
Note that if you have a file with a byte order mark (BOM), you need to skip it before handing the reader to this
library. There's existing classes that do that, e.g. see BOMInputStream in Commons IO.
This method is thread-safe (a new parser state is used for each invocation).
| |
| postProcess | back to summary |
|---|---|
| private Node postProcess(Node document) | |
Parser.
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| private final List | |
| private Set | |
| private IncludeSourceSpans | |
| private InlineParserFactory | |
| private final List |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Parser | |
| public Parser. | Returns: thisa block parser factory implementation blockParserFactory)Adds a custom block parser factory. |
| public Parser. | Returns: thisa delimiter processor implementation delimiterProcessor)Adds a custom delimiter processor. |
| public Parser. | Returns: thisA list of block nodes the parser will parse.
If this list is empty, the parser will not recognize any CommonMark core features. enabledBlockTypes)Describe the list of markdown features the parser will recognize and parse. |
| public Parser. | |
| private InlineParserFactory | |
| public Parser. | Returns: thiswhich kind of source spans should be included includeSourceSpans)Whether to calculate |
| public Parser. | Returns: thisan inline parser factory implementation inlineParserFactory)Overrides the parser used for inline markdown processing. |
| public Parser. |
| blockParserFactories | back to summary |
|---|---|
| private final List<BlockParserFactory> blockParserFactories | |
| delimiterProcessors | back to summary |
|---|---|
| private final List<DelimiterProcessor> delimiterProcessors | |
| enabledBlockTypes | back to summary |
|---|---|
| private Set<Class<? extends Block>> enabledBlockTypes | |
| includeSourceSpans | back to summary |
|---|---|
| private IncludeSourceSpans includeSourceSpans | |
| inlineParserFactory | back to summary |
|---|---|
| private InlineParserFactory inlineParserFactory | |
| postProcessors | back to summary |
|---|---|
| private final List<PostProcessor> postProcessors | |
| Builder | back to summary |
|---|---|
| public Builder() | |
| build | back to summary |
|---|---|
| public Parser build() | |
| customBlockParserFactory | back to summary |
|---|---|
| public Parser. Adds a custom block parser factory. Note that custom factories are applied before the built-in factories. This is so that extensions can change how some syntax is parsed that would otherwise be handled by built-in factories. "With great power comes great responsibility."
| |
| customDelimiterProcessor | back to summary |
|---|---|
| public Parser. Adds a custom delimiter processor. Note that multiple delimiter processors with the same characters can be added, as long as they have a different minimum length. In that case, the processor with the shortest matching length is used. Adding more than one delimiter processor with the same character and minimum length is invalid.
| |
| enabledBlockTypes | back to summary |
|---|---|
| public Parser. Describe the list of markdown features the parser will recognize and parse. By default, CommonMark will recognize and parse the following set of "block" elements:
To parse only a subset of the features listed above, pass a list of each feature's associated E.g., to only parse headings and lists:
| |
| extensions | back to summary |
|---|---|
| public Parser. | |
| getInlineParserFactory | back to summary |
|---|---|
| private InlineParserFactory getInlineParserFactory() | |
| includeSourceSpans | back to summary |
|---|---|
| public Parser. Whether to calculate By default, source spans are disabled.
| |
| inlineParserFactory | back to summary |
|---|---|
| public Parser. Overrides the parser used for inline markdown processing. Provide an implementation of InlineParserFactory which provides a custom inline parser to modify how the following are parsed: bold (**) italic (*) strikethrough (~~) backtick quote (`) link ([title](http://)) image () Note that if this method is not called or the inline parser factory is set to null, then the default implementation will be used.
| |
| postProcessor | back to summary |
|---|---|
| public Parser. | |
Parser.
| Modifier and Type | Method and Description |
|---|---|
| public void |
| extend | back to summary |
|---|---|
| public void extend(Parser. | |