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 Details

  • Method Details

    • getNodes

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

      public Iterator<Map<String,Object>> iterator()
      Specified by:
      iterator in interface Iterable<Map<String,Object>>
    • 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.