Class DocumentParser
- java.lang.Object
-
- com.vladsch.flexmark.parser.internal.DocumentParser
-
- All Implemented Interfaces:
BlockParserTracker
,ParserState
,BlockTracker
public class DocumentParser extends java.lang.Object implements ParserState
-
-
Field Summary
Fields Modifier and Type Field Description static InlineParserFactory
INLINE_PARSER_FACTORY
-
Constructor Summary
Constructors Constructor Description DocumentParser(DataHolder options, java.util.List<CustomBlockParserFactory> customBlockParserFactories, java.util.List<java.util.List<ParagraphPreProcessorFactory>> paragraphPreProcessorDependencies, java.util.List<java.util.List<BlockPreProcessorFactory>> blockPreProcessorDependencies, InlineParser inlineParser)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
blockAdded(Block node)
void
blockAddedWithChildren(Block node)
void
blockAddedWithDescendants(Block node)
void
blockParserAdded(BlockParser blockParser)
void
blockParserRemoved(BlockParser blockParser)
void
blockRemoved(Block node)
void
blockRemovedWithChildren(Block node)
void
blockRemovedWithDescendants(Block node)
static java.util.List<CustomBlockParserFactory>
calculateBlockParserFactories(DataHolder options, java.util.List<CustomBlockParserFactory> customBlockParserFactories)
static java.util.List<java.util.List<BlockPreProcessorFactory>>
calculateBlockPreProcessors(DataHolder options, java.util.List<BlockPreProcessorFactory> blockPreProcessors)
static java.util.List<java.util.List<ParagraphPreProcessorFactory>>
calculateParagraphPreProcessors(DataHolder options, java.util.List<ParagraphPreProcessorFactory> blockPreProcessors, InlineParserFactory inlineParserFactory)
boolean
endsWithBlankLine(Node block)
Test the block to see if it ends in a blank line.BlockParser
getActiveBlockParser()
BlockParser
getActiveBlockParser(Block node)
java.util.List<BlockParser>
getActiveBlockParsers()
int
getColumn()
The column is the position within the line after tab characters have been processed as 4-space tab stops.int
getIndent()
int
getIndex()
InlineParser
getInlineParser()
BasedSequence
getLine()
int
getLineEndIndex()
int
getLineEolLength()
int
getLineNumber()
java.util.List<BasedSequence>
getLineSegments()
Returns a list of document lines encountered this far in the parsing processint
getLineStart()
BasedSequence
getLineWithEOL()
int
getNextNonSpaceIndex()
ParserPhase
getParserPhase()
Get the current parser phaseParsing
getParsing()
MutableDataHolder
getProperties()
boolean
isBlank()
boolean
isBlankLine()
boolean
isLastLineBlank(Node node)
Test a block to see if the last line of the block is blank.Document
parse(java.io.Reader input)
Document
parse(java.lang.CharSequence source)
The main parsing function.
-
-
-
Field Detail
-
INLINE_PARSER_FACTORY
public static final InlineParserFactory INLINE_PARSER_FACTORY
-
-
Constructor Detail
-
DocumentParser
public DocumentParser(DataHolder options, java.util.List<CustomBlockParserFactory> customBlockParserFactories, java.util.List<java.util.List<ParagraphPreProcessorFactory>> paragraphPreProcessorDependencies, java.util.List<java.util.List<BlockPreProcessorFactory>> blockPreProcessorDependencies, InlineParser inlineParser)
-
-
Method Detail
-
getLineSegments
public java.util.List<BasedSequence> getLineSegments()
Description copied from interface:ParserState
Returns a list of document lines encountered this far in the parsing process- Specified by:
getLineSegments
in interfaceParserState
- Returns:
- list of line sequences (including EOLs)
-
blockParserAdded
public void blockParserAdded(BlockParser blockParser)
- Specified by:
blockParserAdded
in interfaceBlockParserTracker
-
blockParserRemoved
public void blockParserRemoved(BlockParser blockParser)
- Specified by:
blockParserRemoved
in interfaceBlockParserTracker
-
blockAdded
public void blockAdded(@NotNull Block node)
- Specified by:
blockAdded
in interfaceBlockTracker
-
blockAddedWithChildren
public void blockAddedWithChildren(@NotNull Block node)
- Specified by:
blockAddedWithChildren
in interfaceBlockTracker
-
blockAddedWithDescendants
public void blockAddedWithDescendants(@NotNull Block node)
- Specified by:
blockAddedWithDescendants
in interfaceBlockTracker
-
blockRemoved
public void blockRemoved(@NotNull Block node)
- Specified by:
blockRemoved
in interfaceBlockTracker
-
blockRemovedWithChildren
public void blockRemovedWithChildren(@NotNull Block node)
- Specified by:
blockRemovedWithChildren
in interfaceBlockTracker
-
blockRemovedWithDescendants
public void blockRemovedWithDescendants(@NotNull Block node)
- Specified by:
blockRemovedWithDescendants
in interfaceBlockTracker
-
getParserPhase
public ParserPhase getParserPhase()
Description copied from interface:ParserState
Get the current parser phase- Specified by:
getParserPhase
in interfaceParserState
- Returns:
- the current parser phase
ParserPhase
-
getParsing
public Parsing getParsing()
- Specified by:
getParsing
in interfaceParserState
- Returns:
- strings and patterns class adjusted for options
Parsing
-
getProperties
public MutableDataHolder getProperties()
- Specified by:
getProperties
in interfaceParserState
- Returns:
- document properties of the document being parsed
-
calculateBlockParserFactories
public static java.util.List<CustomBlockParserFactory> calculateBlockParserFactories(DataHolder options, java.util.List<CustomBlockParserFactory> customBlockParserFactories)
-
calculateParagraphPreProcessors
public static java.util.List<java.util.List<ParagraphPreProcessorFactory>> calculateParagraphPreProcessors(DataHolder options, java.util.List<ParagraphPreProcessorFactory> blockPreProcessors, InlineParserFactory inlineParserFactory)
-
calculateBlockPreProcessors
public static java.util.List<java.util.List<BlockPreProcessorFactory>> calculateBlockPreProcessors(DataHolder options, java.util.List<BlockPreProcessorFactory> blockPreProcessors)
-
getInlineParser
public InlineParser getInlineParser()
- Specified by:
getInlineParser
in interfaceParserState
- Returns:
- inline parser instance for the parser state
-
parse
public Document parse(java.lang.CharSequence source)
The main parsing function. Returns a parsed document AST.- Parameters:
source
- source sequence to parse- Returns:
- Document node of the resulting AST
-
parse
public Document parse(java.io.Reader input) throws java.io.IOException
- Throws:
java.io.IOException
-
getLineNumber
public int getLineNumber()
- Specified by:
getLineNumber
in interfaceParserState
- Returns:
- The 0 based current line number within the input
-
getLineStart
public int getLineStart()
- Specified by:
getLineStart
in interfaceParserState
- Returns:
- the start of line offset into the input stream corresponding to current index into the line
-
getLineEndIndex
public int getLineEndIndex()
- Specified by:
getLineEndIndex
in interfaceParserState
- Returns:
- the end of line offset into the input stream corresponding to current index into the line, including the EOL
-
getLine
public BasedSequence getLine()
- Specified by:
getLine
in interfaceParserState
- Returns:
- the current line
-
getLineWithEOL
public BasedSequence getLineWithEOL()
- Specified by:
getLineWithEOL
in interfaceParserState
- Returns:
- the current line with EOL
-
getLineEolLength
public int getLineEolLength()
- Specified by:
getLineEolLength
in interfaceParserState
- Returns:
- the EOL offset into the input stream corresponding to current index into the line
-
getIndex
public int getIndex()
- Specified by:
getIndex
in interfaceParserState
- Returns:
- the current index within the line (0-based)
-
getNextNonSpaceIndex
public int getNextNonSpaceIndex()
- Specified by:
getNextNonSpaceIndex
in interfaceParserState
- Returns:
- the index of the next non-space character starting from
ParserState.getIndex()
(may be the same) (0-based)
-
getColumn
public int getColumn()
Description copied from interface:ParserState
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 theParserState.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).- Specified by:
getColumn
in interfaceParserState
- Returns:
- the current column within the line (0-based)
-
getIndent
public int getIndent()
- Specified by:
getIndent
in interfaceParserState
- Returns:
- the indentation in columns (either by spaces or tab stop of 4), starting from
ParserState.getColumn()
-
isBlank
public boolean isBlank()
- Specified by:
isBlank
in interfaceParserState
- Returns:
- true if the current line is blank starting from the index
-
isBlankLine
public boolean isBlankLine()
- Specified by:
isBlankLine
in interfaceParserState
- Returns:
- true if the current line is blank starting from the index
-
getActiveBlockParser
public BlockParser getActiveBlockParser()
- Specified by:
getActiveBlockParser
in interfaceParserState
- Returns:
- the deepest open block parser
-
getActiveBlockParser
public BlockParser getActiveBlockParser(Block node)
- Specified by:
getActiveBlockParser
in interfaceParserState
- Parameters:
node
- block node for which to get the active block parser- Returns:
- an active block parser for the node or null if not found or the block is already closed.
-
getActiveBlockParsers
public java.util.List<BlockParser> getActiveBlockParsers()
- Specified by:
getActiveBlockParsers
in interfaceParserState
- Returns:
- the current list of active block parsers, deepest is last
-
endsWithBlankLine
public boolean endsWithBlankLine(Node block)
Description copied from interface:ParserState
Test the block to see if it ends in a blank line. The blank line can be in the block or its last child.- Specified by:
endsWithBlankLine
in interfaceParserState
- Parameters:
block
- block to be tested- Returns:
- true if the block ends in a blank line
-
isLastLineBlank
public boolean isLastLineBlank(Node node)
Description copied from interface:ParserState
Test a block to see if the last line of the block is blank. Children not tested.- Specified by:
isLastLineBlank
in interfaceParserState
- Parameters:
node
- block instance to test- Returns:
- true if the block's last line is blank
-
-