MD::Parser Class
class MD::ParserMarkdown parser. More...
| Header: | #include <md4qt/parser.h> |
| CMake: | find_package(md4qt REQUIRED COMPONENTS md4qt)target_link_libraries(mytarget PRIVATE md4qt::md4qt) |
Public Types
Public Functions
| Parser() | |
| const MD::Parser::BlockParsers & | blockParsers() const |
| MD::BlockParser * | checkBlock(MD::Line &line, MD::TextStream &stream, QSharedPointer<MD::Document> doc, MD::Context &ctx) const |
| MD::BlockParser * | checkBlockExcluding(MD::Line &line, MD::TextStream &stream, QSharedPointer<MD::Document> doc, MD::Context &ctx, const MD::BlockParser *exclude) const |
| MD::Parser::InlineParsers | inlineParsersFor(const QChar &c) const |
| QSharedPointer<MD::Document> | parse(QTextStream &stream, const QString &path, const QString &fileName) |
| QSharedPointer<MD::Document> | parse(const QString &fileName, bool recursive = true, const QStringList &ext = {QStringLiteral("md"), QStringLiteral("markdown")}) |
| QSharedPointer<MD::Document> | parse(const QString &fileName, const QString &workingDirectory, bool recursive = true, const QStringList &ext = {QStringLiteral("md"), QStringLiteral("markdown")}) |
| void | popStateOfInliners() |
| void | pushStateOfInliners() |
| void | setBlockParsers(const MD::Parser::BlockParsers &p) |
| void | setInlineParsers(const MD::Parser::InlineParsers &p) |
Static Public Members
| typename std::enable_if<std::is_base_of<BlockParser, T>::value && !std::is_base_of<InlineParser, T>::value>::type | appendBlockParser(MD::Parser::BlockParsers &parsers, MD::Parser *parser) |
| QSharedPointer<T> | appendInlineParser(MD::Parser::InlineParsers &parsers) |
| MD::Parser::BlockParsers | makeCommonMarkBlockParsersPipeline(MD::Parser *parser) |
| MD::Parser::InlineParsers | makeCommonMarkInlineParsersPipeline() |
| MD::Parser::BlockParsers | makeDefaultBlockParsersPipeline(MD::Parser *parser) |
| MD::Parser::InlineParsers | makeDefaultInlineParsersPipeline() |
Detailed Description
Parser of Markdown.
Member Type Documentation
[alias] Parser::BlockParsers
Vector of block parsers.
[alias] Parser::InlineParsers
Vector of inline parsers.
Member Function Documentation
Parser::Parser()
Default constructor.
GitHub's autolinks extension will be added by default.
[static] template <typename T> typename std::enable_if<std::is_base_of<BlockParser, T>::value && !std::is_base_of<InlineParser, T>::value>::type Parser::appendBlockParser(MD::Parser::BlockParsers &parsers, MD::Parser *parser)
Adds new block parser to pipeline.
parsers Receiver.
parser Parent.
[static] template <typename T, std::enable_if_t<std::is_base_of<InlineParser, T>::value, bool> = true> QSharedPointer<T> Parser::appendInlineParser(MD::Parser::InlineParsers &parsers)
Adds new inline parser into pipeline.
parsers Receiver.
const MD::Parser::BlockParsers &Parser::blockParsers() const
Returns current block parsers pipeline.
See also setBlockParsers().
MD::BlockParser *Parser::checkBlock(MD::Line &line, MD::TextStream &stream, QSharedPointer<MD::Document> doc, MD::Context &ctx) const
Returns block parser for the given line.
Note: During this check line's position won't be moved accordingly.
line Line.
stream Stream.
doc Document.
ctx Context.
MD::BlockParser *Parser::checkBlockExcluding(MD::Line &line, MD::TextStream &stream, QSharedPointer<MD::Document> doc, MD::Context &ctx, const MD::BlockParser *exclude) const
Returns block parser for the given line excluding the given block parser.
Note: During this check line's position won't be moved accordingly.
line Line.
stream Stream.
doc Document.
ctx Context.
exclude Block parser that should be excluded.
MD::Parser::InlineParsers Parser::inlineParsersFor(const QChar &c) const
Returms inline parsers for the given opener symbol.
c Opener symbol.
[static] MD::Parser::BlockParsers Parser::makeCommonMarkBlockParsersPipeline(MD::Parser *parser)
Makes CommonMark pipeline of block parsers.
parser Parent.
[static] MD::Parser::InlineParsers Parser::makeCommonMarkInlineParsersPipeline()
Makes CommonMark pipeline of inline parsers.
[static] MD::Parser::BlockParsers Parser::makeDefaultBlockParsersPipeline(MD::Parser *parser)
Makes default pipeline of block parsers.
parser Parent.
[static] MD::Parser::InlineParsers Parser::makeDefaultInlineParsersPipeline()
Makes default pipeline of inline parsers.
QSharedPointer<MD::Document> Parser::parse(QTextStream &stream, const QString &path, const QString &fileName)
Returns parsed Markdown document.
stream Stream to parse.
path Absolute path to the root folder for the document. This path will be used to resolve local links.
fileName This argument needed only for anchor.
QSharedPointer<MD::Document> Parser::parse(const QString &fileName, bool recursive = true, const QStringList &ext = {QStringLiteral("md"), QStringLiteral("markdown")})
Returns Parsed Markdown document.
fileName File name of the Markdown document.
recursive Should parsing be recursive? If recursive all links to existing Markdown files will be parsed and presented in the returned document.
ext Allowed extensions for Markdonw document files. If Markdown file doesn't have given extension it will be ignored.
QSharedPointer<MD::Document> Parser::parse(const QString &fileName, const QString &workingDirectory, bool recursive = true, const QStringList &ext = {QStringLiteral("md"), QStringLiteral("markdown")})
Returns parsed Markdown document.
fileName File name of the Markdown document (full path).
workingDirectory Absolute path to the working directory for the document. This path will be used to resolve local links.
Warning: This path should be in fileName path.
recursive Should parsing be recursive? If recursive all links to existing Markdown files will be parsed and presented in the returned document.
ext Allowed extensions for Markdonw document files. If Markdown file doesn't have given extension it will be ignored.
void Parser::popStateOfInliners()
Pop state of all inline parsers.
void Parser::pushStateOfInliners()
Push state of all inline parsers.
void Parser::setBlockParsers(const MD::Parser::BlockParsers &p)
Set current block parsers pipeline.
p Pipeline.
See also blockParsers().
void Parser::setInlineParsers(const MD::Parser::InlineParsers &p)
Set current inline parsers pipeline.
p Pipeline.