@Incubating
public class MarkdownSlurper
extends Object
Parses CommonMark Markdown into a MarkdownDocument backed by nested lists and maps.
Usage:
def doc = new groovy.markdown.MarkdownSlurper().parseText('# Hello')
assert doc.headings[0].text == 'Hello'
GFM-style tables are supported via an optional extension. Call
enableTables(boolean) enableTables(true) after adding
org.commonmark:commonmark-ext-gfm-tables to the runtime classpath.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public MarkdownSlurper |
enableTables(boolean enable)Enable GFM-style tables. |
|
public MarkdownDocument |
parse(Reader reader)Parses Markdown content from a reader. |
|
public MarkdownDocument |
parse(InputStream stream)Parses Markdown content from an input stream. |
|
public MarkdownDocument |
parse(File file)Parses Markdown content from a file. |
|
public MarkdownDocument |
parse(Path path)Parses Markdown content from a path. |
|
public MarkdownDocument |
parseText(String md)Parses Markdown text into a MarkdownDocument. |
Enable GFM-style tables. Requires commonmark-ext-gfm-tables on the classpath.
enable is true but the extension jar is missingenable - whether to enable table parsingParses Markdown content from a reader.
reader - the reader supplying Markdown contentParses Markdown content from an input stream. The caller remains responsible for closing the stream.
stream - the input stream supplying Markdown contentParses Markdown content from a file.
file - the file to readParses Markdown content from a path.
path - the path to readParses Markdown text into a MarkdownDocument.
md - the Markdown text to parse