Class AbstractBlockParser

java.lang.Object
org.commonmark.parser.block.AbstractBlockParser
All Implemented Interfaces:
BlockParser
Direct Known Subclasses:
BlockQuoteParser, DocumentBlockParser, FencedCodeBlockParser, HeadingParser, HtmlBlockParser, IndentedCodeBlockParser, ListBlockParser, ListItemParser, ParagraphParser, TableBlockParser, ThematicBreakParser, YamlFrontMatterBlockParser

public abstract class AbstractBlockParser extends Object implements BlockParser
  • Constructor Details

    • AbstractBlockParser

      public AbstractBlockParser()
  • Method Details

    • isContainer

      public boolean isContainer()
      Description copied from interface: BlockParser
      Return true if the block that is parsed is a container (contains other blocks), or false if it's a leaf.
      Specified by:
      isContainer in interface BlockParser
    • canHaveLazyContinuationLines

      public boolean canHaveLazyContinuationLines()
      Description copied from interface: BlockParser
      Return true if the block can have lazy continuation lines.

      Lazy continuation lines are lines that were rejected by this BlockParser.tryContinue(ParserState) but didn't match any other block parsers either.

      If true is returned here, those lines will get added via BlockParser.addLine(SourceLine). For false, the block is closed instead.

      Specified by:
      canHaveLazyContinuationLines in interface BlockParser
    • canContain

      public boolean canContain(Block childBlock)
      Specified by:
      canContain in interface BlockParser
    • addLine

      public void addLine(SourceLine line)
      Description copied from interface: BlockParser
      Add the part of a line that belongs to this block parser to parse (i.e. without any container block markers). Note that the line will only include a SourceLine.getSourceSpan() if source spans are enabled for inlines.
      Specified by:
      addLine in interface BlockParser
    • addSourceSpan

      public void addSourceSpan(SourceSpan sourceSpan)
      Description copied from interface: BlockParser
      Add a source span of the currently parsed block. The default implementation in AbstractBlockParser adds it to the block. Unless you have some complicated parsing where you need to check source positions, you don't need to override this.
      Specified by:
      addSourceSpan in interface BlockParser
    • closeBlock

      public void closeBlock()
      Specified by:
      closeBlock in interface BlockParser
    • parseInlines

      public void parseInlines(InlineParser inlineParser)
      Specified by:
      parseInlines in interface BlockParser