Top Inners Fields Constructors Methods
jdk.internal.org.commonmark.internal

public Class DocumentParser

extends Object
implements ParserState
Class Inheritance
All Implemented Interfaces
jdk.internal.org.commonmark.parser.block.ParserState
Imports
jdk.internal.org.commonmark.internal.util.Parsing, jdk.internal.org.commonmark.node.*, jdk.internal.org.commonmark.parser.*, jdk.internal.org.commonmark.parser.block.*, jdk.internal.org.commonmark.parser.delimiter.DelimiterProcessor, jdk.internal.org.commonmark.text.Characters, java.io.BufferedReader, .IOException, .Reader, java.util.*

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final List<BlockParser>
private boolean
private final List<BlockParserFactory>
private int
column

current column of input line (tab causes column to go to next 4-space tab stop) (0-based)

private boolean
columnIsInTab

if the current column is within a tab character (partially consumed tab)

private static final Set<Class<? extends Block>>
private final LinkReferenceDefinitions
private final List<DelimiterProcessor>
private final DocumentBlockParser
private final IncludeSourceSpans
private int
private int
index

current index (offset) in input line (0-based)

private final InlineParserFactory
private SourceLine
private int
lineIndex

Line index (0-based)

private int
private int
private static final Map<Class<? extends Block>, BlockParserFactory>
private final List<DocumentParser.OpenBlockParser>

Constructor Summary

AccessConstructor and Description
public
DocumentParser(List<BlockParserFactory> blockParserFactories, InlineParserFactory inlineParserFactory, List<DelimiterProcessor> delimiterProcessors, IncludeSourceSpans includeSourceSpans)

Method Summary

Modifier and TypeMethod and Description
private void
private void
addChild(DocumentParser.OpenBlockParser openBlockParser)

Add block of type tag as a child of the tip.

private void
private void
addLine()

Add line content to the active block parser.

private void
private void
public static List<BlockParserFactory>
calculateBlockParserFactories(List<BlockParserFactory> customBlockParserFactories, Set<Class<? extends Block>> enabledBlockTypes)

public static void
checkEnabledBlockTypes(Set<Class<? extends Block>> enabledBlockTypes)

private void
closeBlockParsers(int count)

private DocumentParser.OpenBlockParser
private void
finalize(BlockParser blockParser)

Finalize a block.

private Document
private BlockStartImpl
private void
public BlockParser
public int
getColumn()

Implements jdk.internal.org.commonmark.parser.block.ParserState.getColumn.

The column is the position within the line after tab characters have been processed as 4-space tab stops.

public static Set<Class<? extends Block>>
public int
public int
public SourceLine
public int
public boolean
public Document
parse(String input)

The main parsing function.

public Document
parse(Reader input)

private void
parseLine(CharSequence ln)

Analyze a line of text and update the document appropriately.

private Block
private static CharSequence
prepareLine(CharSequence line)

Prepares the input line replacing \0

private void
processInlines()

Walk through a block & children recursively, parsing string content into inline content where appropriate.

private void
private void
setNewColumn(int newColumn)

private void
setNewIndex(int newIndex)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allBlockParsersback to summary
private final List<BlockParser> allBlockParsers
blankback to summary
private boolean blank
blockParserFactoriesback to summary
private final List<BlockParserFactory> blockParserFactories
columnback to summary
private int column

current column of input line (tab causes column to go to next 4-space tab stop) (0-based)

columnIsInTabback to summary
private boolean columnIsInTab

if the current column is within a tab character (partially consumed tab)

CORE_FACTORY_TYPESback to summary
private static final Set<Class<? extends Block>> CORE_FACTORY_TYPES
definitionsback to summary
private final LinkReferenceDefinitions definitions
delimiterProcessorsback to summary
private final List<DelimiterProcessor> delimiterProcessors
documentBlockParserback to summary
private final DocumentBlockParser documentBlockParser
includeSourceSpansback to summary
private final IncludeSourceSpans includeSourceSpans
indentback to summary
private int indent
indexback to summary
private int index

current index (offset) in input line (0-based)

inlineParserFactoryback to summary
private final InlineParserFactory inlineParserFactory
lineback to summary
private SourceLine line
lineIndexback to summary
private int lineIndex

Line index (0-based)

nextNonSpaceback to summary
private int nextNonSpace
nextNonSpaceColumnback to summary
private int nextNonSpaceColumn
NODES_TO_CORE_FACTORIESback to summary
private static final Map<Class<? extends Block>, BlockParserFactory> NODES_TO_CORE_FACTORIES
openBlockParsersback to summary
private final List<DocumentParser.OpenBlockParser> openBlockParsers

Constructor Detail

DocumentParserback to summary
public DocumentParser(List<BlockParserFactory> blockParserFactories, InlineParserFactory inlineParserFactory, List<DelimiterProcessor> delimiterProcessors, IncludeSourceSpans includeSourceSpans)

Method Detail

activateBlockParserback to summary
private void activateBlockParser(DocumentParser.OpenBlockParser openBlockParser)
addChildback to summary
private void addChild(DocumentParser.OpenBlockParser openBlockParser)

Add block of type tag as a child of the tip. If the tip can't accept children, close and finalize it and try its parent, and so on until we find a block that can accept children.

addDefinitionsFromback to summary
private void addDefinitionsFrom(ParagraphParser paragraphParser)
addLineback to summary
private void addLine()

Add line content to the active block parser. We assume it can accept lines -- that check should be done before calling this.

addSourceSpansback to summary
private void addSourceSpans()
advanceback to summary
private void advance()
calculateBlockParserFactoriesback to summary
public static List<BlockParserFactory> calculateBlockParserFactories(List<BlockParserFactory> customBlockParserFactories, Set<Class<? extends Block>> enabledBlockTypes)
checkEnabledBlockTypesback to summary
public static void checkEnabledBlockTypes(Set<Class<? extends Block>> enabledBlockTypes)
closeBlockParsersback to summary
private void closeBlockParsers(int count)
deactivateBlockParserback to summary
private DocumentParser.OpenBlockParser deactivateBlockParser()
finalizeback to summary
private void finalize(BlockParser blockParser)

Finalize a block. Close it and do any necessary postprocessing, e.g. setting the content of blocks and collecting link reference definitions from paragraphs.

finalizeAndProcessback to summary
private Document finalizeAndProcess()
findBlockStartback to summary
private BlockStartImpl findBlockStart(BlockParser blockParser)
findNextNonSpaceback to summary
private void findNextNonSpace()
getActiveBlockParserback to summary
public BlockParser getActiveBlockParser()

Implements jdk.internal.org.commonmark.parser.block.ParserState.getActiveBlockParser.

Returns:BlockParser

Doc from jdk.internal.org.commonmark.parser.block.ParserState.getActiveBlockParser.

the deepest open block parser

Annotations
@Override
getColumnback to summary
public int getColumn()

Implements jdk.internal.org.commonmark.parser.block.ParserState.getColumn.

Doc from jdk.internal.org.commonmark.parser.block.ParserState.getColumn.

The column is the position within the line after tab characters have been processed as 4-space tab stops. If the line doesn't contain any tabs, it's the same as the getIndex(). If the line starts with a tab, followed by text, then the column for the first character of the text is 4 (the index is 1).

Returns:int

the current column within the line (0-based)

Annotations
@Override
getDefaultBlockParserTypesback to summary
public static Set<Class<? extends Block>> getDefaultBlockParserTypes()
getIndentback to summary
public int getIndent()

Implements jdk.internal.org.commonmark.parser.block.ParserState.getIndent.

Returns:int

Doc from jdk.internal.org.commonmark.parser.block.ParserState.getIndent.

the indentation in columns (either by spaces or tab stop of 4), starting from getColumn()

Annotations
@Override
getIndexback to summary
public int getIndex()

Implements jdk.internal.org.commonmark.parser.block.ParserState.getIndex.

Returns:int

Doc from jdk.internal.org.commonmark.parser.block.ParserState.getIndex.

the current index within the line (0-based)

Annotations
@Override
getLineback to summary
public SourceLine getLine()

Implements jdk.internal.org.commonmark.parser.block.ParserState.getLine.

Returns:SourceLine

Doc from jdk.internal.org.commonmark.parser.block.ParserState.getLine.

the current source line being parsed (full line)

Annotations
@Override
getNextNonSpaceIndexback to summary
public int getNextNonSpaceIndex()

Implements jdk.internal.org.commonmark.parser.block.ParserState.getNextNonSpaceIndex.

Returns:int

Doc from jdk.internal.org.commonmark.parser.block.ParserState.getNextNonSpaceIndex.

the index of the next non-space character starting from getIndex() (may be the same) (0-based)

Annotations
@Override
isBlankback to summary
public boolean isBlank()

Implements jdk.internal.org.commonmark.parser.block.ParserState.isBlank.

Returns:boolean

Doc from jdk.internal.org.commonmark.parser.block.ParserState.isBlank.

true if the current line is blank starting from the index

Annotations
@Override
parseback to summary
public Document parse(String input)

The main parsing function. Returns a parsed document AST.

parseback to summary
public Document parse(Reader input) throws IOException
parseLineback to summary
private void parseLine(CharSequence ln)

Analyze a line of text and update the document appropriately. We parse markdown text by calling this on each line of input, then finalizing the document.

prepareActiveBlockParserForReplacementback to summary
private Block prepareActiveBlockParserForReplacement()
prepareLineback to summary
private static CharSequence prepareLine(CharSequence line)

Prepares the input line replacing \0

processInlinesback to summary
private void processInlines()

Walk through a block & children recursively, parsing string content into inline content where appropriate.

setLineback to summary
private void setLine(CharSequence ln)
setNewColumnback to summary
private void setNewColumn(int newColumn)
setNewIndexback to summary
private void setNewIndex(int newIndex)
jdk.internal.org.commonmark.internal back to summary

private Class DocumentParser.MatchedBlockParserImpl

extends Object
implements MatchedBlockParser
Class Inheritance
  • java.lang.Object
  • jdk.internal.org.commonmark.internal.DocumentParser.MatchedBlockParserImpl
All Implemented Interfaces
jdk.internal.org.commonmark.parser.block.MatchedBlockParser

Field Summary

Modifier and TypeField and Description
private final BlockParser

Constructor Summary

AccessConstructor and Description
public
MatchedBlockParserImpl(BlockParser matchedBlockParser)

Method Summary

Modifier and TypeMethod and Description
public BlockParser
public SourceLines
getParagraphLines()

Implements jdk.internal.org.commonmark.parser.block.MatchedBlockParser.getParagraphLines.

Returns the current paragraph lines if the matched block is a paragraph.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

matchedBlockParserback to summary
private final BlockParser matchedBlockParser

Constructor Detail

MatchedBlockParserImplback to summary
public MatchedBlockParserImpl(BlockParser matchedBlockParser)

Method Detail

getMatchedBlockParserback to summary
public BlockParser getMatchedBlockParser()

Implements jdk.internal.org.commonmark.parser.block.MatchedBlockParser.getMatchedBlockParser.

Annotations
@Override
getParagraphLinesback to summary
public SourceLines getParagraphLines()

Implements jdk.internal.org.commonmark.parser.block.MatchedBlockParser.getParagraphLines.

Doc from jdk.internal.org.commonmark.parser.block.MatchedBlockParser.getParagraphLines.

Returns the current paragraph lines if the matched block is a paragraph.

Returns:SourceLines

paragraph content or an empty list

Annotations
@Override
jdk.internal.org.commonmark.internal back to summary

private Class DocumentParser.OpenBlockParser

extends Object
Class Inheritance
  • java.lang.Object
  • jdk.internal.org.commonmark.internal.DocumentParser.OpenBlockParser

Field Summary

Modifier and TypeField and Description
private final BlockParser
private int

Constructor Summary

AccessConstructor and Description
pack-priv
OpenBlockParser(BlockParser blockParser, int sourceIndex)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blockParserback to summary
private final BlockParser blockParser
sourceIndexback to summary
private int sourceIndex

Constructor Detail

OpenBlockParserback to summary
pack-priv OpenBlockParser(BlockParser blockParser, int sourceIndex)