MD::BlockParser Class

class MD::BlockParser

Base class for parsing a block. More...

Header: #include <md4qt/block_parser.h>
CMake: find_package(md4qt REQUIRED COMPONENTS md4qt)
target_link_libraries(mytarget PRIVATE md4qt::md4qt)
Inherited By:

MD::ATXHeadingParser, MD::BlockquoteParser, MD::FencedCodeParser, MD::FootnoteParser, MD::HTMLParser, MD::IndentedCodeParser, MD::ListParser, MD::ParagraphParser, MD::SetextHeadingParser, MD::TableParser, MD::ThematicBreakParser, and MD::YAMLParser

Public Functions

virtual bool canBeLazyLine(MD::Line &line, MD::TextStream &stream, QSharedPointer<MD::Document> doc, MD::Context &ctx) const
virtual MD::BlockState check(MD::Line &currentLine, MD::TextStream &stream, QSharedPointer<MD::Document> doc, MD::Context &ctx, const QString &path, const QString &fileName, bool checkWithoutProcessing = false) = 0
virtual MD::BlockState continueCheck(MD::Line &currentLine, MD::TextStream &stream, QSharedPointer<MD::Document> doc, MD::Context &ctx, const QString &path, const QString &fileName) = 0
virtual QSharedPointer<MD::Block> currentBlock(const MD::Context &ctx) const
virtual void finish(MD::Line &currentLine, MD::TextStream &stream, QSharedPointer<MD::Document> doc, QSharedPointer<MD::Block> parent, MD::Context &ctx, const QString &path, const QString &fileName, QStringList &linksToParse)
bool isLazyContinuationLine(MD::Line &line, MD::TextStream &stream, QSharedPointer<MD::Document> doc, MD::Context &ctx, bool considerIndents) const
virtual bool isNotFinishedDiscardable() const
virtual bool mayBreakParagraph(MD::Line &line, MD::TextStream &stream, QSharedPointer<MD::Document> doc, MD::Context &ctx) const = 0
MD::Parser *parser() const
virtual MD::BlockState process(MD::Line &currentLine, MD::TextStream &stream, QSharedPointer<MD::Document> doc, QSharedPointer<MD::Block> parent, MD::Context &ctx, const QString &path, const QString &fileName, QStringList &linksToParse)
virtual void reset(MD::Context &ctx) = 0
virtual void resetOnAllContexts() = 0

Protected Functions

virtual MD::BlockState processOneTime(MD::Line &currentLine, MD::TextStream &stream, QSharedPointer<MD::Document> doc, QSharedPointer<MD::Block> parent, MD::Context &ctx, const QString &path, const QString &fileName, QStringList &linksToParse)

Detailed Description

Instances of this class invoke during parsing process for checking specific rules to handle this or that type of a block.

Member Function Documentation

[virtual] bool BlockParser::canBeLazyLine(MD::Line &line, MD::TextStream &stream, QSharedPointer<MD::Document> doc, MD::Context &ctx) const

Returns whether this kind of block can be a lazy line.

line Line.

stream Stream.

doc Document.

ctx Context.

[pure virtual] MD::BlockState BlockParser::check(MD::Line &currentLine, MD::TextStream &stream, QSharedPointer<MD::Document> doc, MD::Context &ctx, const QString &path, const QString &fileName, bool checkWithoutProcessing = false)

Returns check state for the current line and block type. This method should return BlockState::None if this string is not handled by him. This method should not return BlockState::Stop ever. If this block parser knows how to handle the current line it should return BlockState::Continue.

currentLine Current processing line.

stream Stream of the lines.

doc Current document.

ctx Current parsing context.

path Path to Markdown file.

fileName File name of the Markdown file.

checkWithoutProcessing Flags to don't do real processing, just check this parser handles this line.

[pure virtual] MD::BlockState BlockParser::continueCheck(MD::Line &currentLine, MD::TextStream &stream, QSharedPointer<MD::Document> doc, MD::Context &ctx, const QString &path, const QString &fileName)

Continue check. If checking knows that block is finished it should return BlockState::Stop.

currentLine Current processing line.

stream Stream of the lines.

doc Current document.

ctx Current parsing context.

path Path to Markdown file.

fileName File name of the Markdown file.

[virtual] QSharedPointer<MD::Block> BlockParser::currentBlock(const MD::Context &ctx) const

Returns current block.

ctx Context.

[virtual] void BlockParser::finish(MD::Line &currentLine, MD::TextStream &stream, QSharedPointer<MD::Document> doc, QSharedPointer<MD::Block> parent, MD::Context &ctx, const QString &path, const QString &fileName, QStringList &linksToParse)

Finish things. This method invokes after MD::BlockState::Stop state recieved or at the end of file.

currentLine Current processing line.

stream Stream of the lines.

doc Document.

parent Parent of this block.

ctx Current parsing context.

path Path to Markdown file.

fileName File name of the Markdown file.

linksToParse List of links for further parsing.

bool BlockParser::isLazyContinuationLine(MD::Line &line, MD::TextStream &stream, QSharedPointer<MD::Document> doc, MD::Context &ctx, bool considerIndents) const

Returns whether the given line is a paragraph continuation.

line Line.

stream Stream.

doc Document.

ctx Context.

considerIndents Whether indents should be considered?

[virtual] bool BlockParser::isNotFinishedDiscardable() const

Returns whether not finished block will be discarded.

[pure virtual] bool BlockParser::mayBreakParagraph(MD::Line &line, MD::TextStream &stream, QSharedPointer<MD::Document> doc, MD::Context &ctx) const

Return whether this kind of block may break a paragraph.

line Line.

stream Stream.

doc Document.

ctx Context.

MD::Parser *BlockParser::parser() const

Returns pointer to parser.

[virtual] MD::BlockState BlockParser::process(MD::Line &currentLine, MD::TextStream &stream, QSharedPointer<MD::Document> doc, QSharedPointer<MD::Block> parent, MD::Context &ctx, const QString &path, const QString &fileName, QStringList &linksToParse)

Process block - do actual parsing and populating MD::Document. If starting empty line is not a subject for work for this kind of block this method should just skip the line. When parsing of a block is finished this method should return BlockState::Stop.

This method should call himself on all children contexts till block finish.

currentLine Current processing line.

stream Stream of the lines.

doc Document.

parent Parent of this block.

ctx Current parsing context.

path Path to Markdown file.

fileName File name of the Markdown file.

linksToParse List of links for further parsing.

[virtual protected] MD::BlockState BlockParser::processOneTime(MD::Line &currentLine, MD::TextStream &stream, QSharedPointer<MD::Document> doc, QSharedPointer<MD::Block> parent, MD::Context &ctx, const QString &path, const QString &fileName, QStringList &linksToParse)

Process block - do actual parsing and populating MD::Document. If starting empty line is not a subject for work for this kind of block this method should just skip the line. When parsing of a block is finished this method should return BlockState::Stop.

This method should call himself on all children contexts till block finish.

currentLine Current processing line.

stream Stream of the lines.

doc Document.

parent Parent of this block.

ctx Current parsing context.

path Path to Markdown file.

fileName File name of the Markdown file.

linksToParse List of links for further parsing.

[pure virtual] void BlockParser::reset(MD::Context &ctx)

Reset state of the block parser for further reuse on the given context.

ctx Context.

[pure virtual] void BlockParser::resetOnAllContexts()

Reset state of the block parser for further reuse.