| Modifier and Type | Class and Description |
|---|---|
static class |
Parser.Builder
Builder for configuring a
Parser. |
static interface |
Parser.ParserExtension
Extension for
Parser. |
| Modifier and Type | Method and Description |
|---|---|
static Parser.Builder |
builder()
Create a new builder for configuring a
Parser. |
Node |
parse(String input)
Parse the specified input text into a tree of nodes.
|
Node |
parseReader(Reader input)
Parse the specified reader into a tree of nodes.
|
public static Parser.Builder builder()
Parser.public Node parse(String input)
This method is thread-safe (a new parser state is used for each invocation).
input - the text to parse - must not be nullpublic Node parseReader(Reader input) throws IOException
Parser parser = Parser.builder().build();
try (InputStreamReader reader = new InputStreamReader(new FileInputStream("file.md"), StandardCharsets.UTF_8)) {
Node document = parser.parseReader(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).
input - the reader to parse - must not be nullIOException - when reading throws an exceptionCopyright © 2021. All rights reserved.