Package: groovy.markdown

## [Java] Class MarkdownDocument

- groovy.markdown.MarkdownDocument

- All Implemented Interfaces and Traits:
    Iterable

      @Incubating
      public class MarkdownDocument
      extends Object
      implements Iterable

  A parsed Markdown document, exposed as a list of node maps with convenience accessors for the most common navigation patterns.

  Each node is a Map with at least a `type` key. The raw structure supports all standard Groovy list/map operations (e.g. `findAll`, `each`, `*.text`); the convenience accessors below recursively walk the tree so nested code blocks, links, etc. are included.

  Since:
    6.0.0

- - ### Constructor Summary

    Constructors
    Constructor and description
    `MarkdownDocument(List<Map<String, Object>> nodes)` Creates a document view over the parsed top-level Markdown nodes.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public List<Map<String, Object>>` | `getCodeBlocks()` All fenced and indented code blocks anywhere in the document.
    `` | `public List<Map<String, Object>>` | `getHeadings()` All headings anywhere in the document, in document order.
    `` | `public List<Map<String, Object>>` | `getLinks()` All links anywhere in the document.
    `` | `public List<Map<String, Object>>` | `getNodes()` The raw top-level nodes of the document.
    `` | `public List<Map<String, Object>>` | `getTables()` All tables anywhere in the document.
    `` | `public String` | `getText()` Plain-text projection of the document — formatting markers are stripped and block-level elements are separated by newlines.
    `` | `public Iterator<Map<String, Object>>` | `iterator()` Returns an iterator over the document's top-level nodes.
    `` | `public List<Map<String, Object>>` | `section(String headingText)` Return the nodes under the heading with the given text, up to the next heading of the same or higher level.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### public MarkdownDocument(List<Map<String, Object>> nodes)

      Creates a document view over the parsed top-level Markdown nodes.

      Parameters:
        `nodes` - the top-level nodes in document order

  - ### Method Detail

    - #### public List<Map<String, Object>> getCodeBlocks()

      All fenced and indented code blocks anywhere in the document.

    - #### public List<Map<String, Object>> getHeadings()

      All headings anywhere in the document, in document order.

    - #### public List<Map<String, Object>> getLinks()

      All links anywhere in the document.

    - #### public List<Map<String, Object>> getNodes()

      The raw top-level nodes of the document.

    - #### public List<Map<String, Object>> getTables()

      All tables anywhere in the document. Tables are only produced when `enableTables(true)` was set on the slurper.

    - #### public String getText()

      Plain-text projection of the document — formatting markers are stripped and block-level elements are separated by newlines.

    - #### public Iterator<Map<String, Object>> iterator()

      Returns an iterator over the document's top-level nodes.

      Returns:
        an iterator for the top-level nodes

    - #### public List<Map<String, Object>> section(String headingText)

      Return the nodes under the heading with the given text, up to the next heading of the same or higher level. The heading itself is not included. Returns an empty list if no matching heading is found.

      Only top-level headings are considered; headings nested inside block quotes or list items are not searched, since the section boundary concept does not naturally extend to such positions.