Class Node

java.lang.Object
org.commonmark.node.Node
Direct Known Subclasses:
Block, Code, CustomNode, Emphasis, HardLineBreak, HtmlInline, Image, Link, LinkReferenceDefinition, SoftLineBreak, StrongEmphasis, Text

public abstract class Node extends Object
The base class of all CommonMark AST nodes (Block and inlines).

A node can have multiple children, and a parent (except for the root node).

  • Field Details

    • parent

      private Node parent
    • firstChild

      private Node firstChild
    • lastChild

      private Node lastChild
    • prev

      private Node prev
    • next

      private Node next
    • sourceSpans

      private List<SourceSpan> sourceSpans
  • Constructor Details

    • Node

      public Node()
  • Method Details

    • accept

      public abstract void accept(Visitor visitor)
    • getNext

      public Node getNext()
    • getPrevious

      public Node getPrevious()
    • getFirstChild

      public Node getFirstChild()
    • getLastChild

      public Node getLastChild()
    • getParent

      public Node getParent()
    • setParent

      protected void setParent(Node parent)
    • appendChild

      public void appendChild(Node child)
    • prependChild

      public void prependChild(Node child)
    • unlink

      public void unlink()
    • insertAfter

      public void insertAfter(Node sibling)
    • insertBefore

      public void insertBefore(Node sibling)
    • getSourceSpans

      public List<SourceSpan> getSourceSpans()
      Returns:
      the source spans of this node if included by the parser, an empty list otherwise
      Since:
      0.16.0
    • setSourceSpans

      public void setSourceSpans(List<SourceSpan> sourceSpans)
      Replace the current source spans with the provided list.
      Parameters:
      sourceSpans - the new source spans to set
      Since:
      0.16.0
    • addSourceSpan

      public void addSourceSpan(SourceSpan sourceSpan)
      Add a source span to the end of the list.
      Parameters:
      sourceSpan - the source span to add
      Since:
      0.16.0
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toStringAttributes

      protected String toStringAttributes()