Package groovy.markdown

# Class MarkdownDocument

java.lang.Object
groovy.markdown.MarkdownDocument

All Implemented Interfaces:
  `Iterable<Map<String,Object>>`

@Incubating public class MarkdownDocument extends Object implements Iterable<Map<String,Object>>
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
  Description
  `MarkdownDocument(List<Map<String,Object>> nodes)`
  Creates a document view over the parsed top-level Markdown nodes.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `List<Map<String,Object>>`
  `getCodeBlocks()`
  All fenced and indented code blocks anywhere in the document.
  `List<Map<String,Object>>`
  `getHeadings()`
  All headings anywhere in the document, in document order.
  `List<Map<String,Object>>`
  `getLinks()`
  All links anywhere in the document.
  `List<Map<String,Object>>`
  `getNodes()`
  The raw top-level nodes of the document.
  `List<Map<String,Object>>`
  `getTables()`
  All tables anywhere in the document.
  `String`
  `getText()`
  Plain-text projection of the document — formatting markers are stripped and block-level elements are separated by newlines.
  `Iterator<Map<String,Object>>`
  `iterator()`
  Returns an iterator over the document's top-level nodes.
  `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.

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

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

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## Constructor Details

  - ### MarkdownDocument

    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 Details

  - ### getNodes

    public List<Map<String,Object>> getNodes()
    The raw top-level nodes of the document.

  - ### iterator

    public Iterator<Map<String,Object>> iterator()
    Returns an iterator over the document's top-level nodes.
    Specified by:
      `iterator` in interface `Iterable<Map<String,Object>>`
    Returns:
      an iterator for the top-level nodes

  - ### getCodeBlocks

    public List<Map<String,Object>> getCodeBlocks()
    All fenced and indented code blocks anywhere in the document.

  - ### getHeadings

    public List<Map<String,Object>> getHeadings()
    All headings anywhere in the document, in document order.

  - ### getLinks

    public List<Map<String,Object>> getLinks()
    All links anywhere in the document.

  - ### getTables

    public List<Map<String,Object>> getTables()
    All tables anywhere in the document. Tables are only produced when `enableTables(true)` was set on the slurper.

  - ### getText

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

  - ### section

    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.