Package groovy.markdown

# Class MarkdownSlurper

java.lang.Object
groovy.markdown.MarkdownSlurper

@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(true)` after adding `org.commonmark:commonmark-ext-gfm-tables` to the runtime classpath.

Since:
  6.0.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MarkdownSlurper()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `MarkdownSlurper`
  `enableTables(boolean enable)`
  Enable GFM-style tables.
  `MarkdownDocument`
  `parse(File file)`
  Parses Markdown content from a file.
  `MarkdownDocument`
  `parse(InputStream stream)`
  Parses Markdown content from an input stream.
  `MarkdownDocument`
  `parse(Reader reader)`
  Parses Markdown content from a reader.
  `MarkdownDocument`
  `parse(Path path)`
  Parses Markdown content from a path.
  `MarkdownDocument`
  `parseText(String md)`
  Parses Markdown text into a `MarkdownDocument`.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### MarkdownSlurper

    public MarkdownSlurper()

- ## Method Details

  - ### enableTables

    public MarkdownSlurper enableTables(boolean enable)
    Enable GFM-style tables. Requires `commonmark-ext-gfm-tables` on the classpath.
    Parameters:
      `enable` - whether to enable table parsing
    Returns:
      this slurper for chaining
    Throws:
      `MarkdownRuntimeException` - if `enable` is true but the extension jar is missing

  - ### parseText

    public MarkdownDocument parseText(String md)
    Parses Markdown text into a `MarkdownDocument`.
    Parameters:
      `md` - the Markdown text to parse
    Returns:
      the parsed document, or an empty document when the input is null or empty

  - ### parse

    public MarkdownDocument parse(Reader reader)
    Parses Markdown content from a reader.
    Parameters:
      `reader` - the reader supplying Markdown content
    Returns:
      the parsed document

  - ### parse

    public MarkdownDocument parse(InputStream stream)
    Parses Markdown content from an input stream. The caller remains responsible for closing the stream.
    Parameters:
      `stream` - the input stream supplying Markdown content
    Returns:
      the parsed document

  - ### parse

    public MarkdownDocument parse(File file) throws IOException
    Parses Markdown content from a file.
    Parameters:
      `file` - the file to read
    Returns:
      the parsed document
    Throws:
      `IOException` - if the file cannot be read

  - ### parse

    public MarkdownDocument parse(Path path) throws IOException
    Parses Markdown content from a path.
    Parameters:
      `path` - the path to read
    Returns:
      the parsed document
    Throws:
      `IOException` - if the path cannot be read