Class Parser
java.lang.Object
org.commonmark.parser.Parser
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic Parser.Builderbuilder()Create a new builder for configuring aParser.Parse the specified input text into a tree of nodes.parseReader(Reader input) Parse the specified reader into a tree of nodes.
-
Method Details
-
builder
Create a new builder for configuring aParser.- Returns:
- a builder
-
parse
-
parseReader
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. seeParser parser = Parser.builder().build(); try (InputStreamReader reader = new InputStreamReader(new FileInputStream("file.md"), StandardCharsets.UTF_8)) { Node document = parser.parseReader(reader); // ... }BOMInputStreamin Commons IO.This method is thread-safe (a new parser state is used for each invocation).
- Parameters:
input- the reader to parse - must not be null- Returns:
- the root node
- Throws:
IOException- when reading throws an exception
-