MD::Parser Class

template <typename Trait> class MD::Parser

Markdown parser. More...

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

Public Functions

Parser()
void addBlockPlugin(std::shared_ptr<MD::BlockPlugin<Trait>> plugin)
void addTextPlugin(MD::TextPlugin id, MD::TextPluginFunc<Trait> plugin, bool processInLinks, const typename Trait::StringList &userData)
std::shared_ptr<MD::Document<Trait>> parse(const typename Trait::String &fileName, bool recursive = true, const typename Trait::StringList &ext = {Trait::latin1ToString("md"), Trait::latin1ToString("markdown")}, bool fullyOptimizeParagraphs = true)
std::shared_ptr<MD::Document<Trait>> parse(typename Trait::TextStream &stream, const typename Trait::String &path, const typename Trait::String &fileName, bool fullyOptimizeParagraphs = true)
std::shared_ptr<MD::Document<Trait>> parse(const typename Trait::String &fileName, const typename Trait::String &workingDirectory, bool recursive = true, const typename Trait::StringList &ext = {Trait::latin1ToString("md"), Trait::latin1ToString("markdown")}, bool fullyOptimizeParagraphs = true)
void removeBlockPlugin(MD::BlockType id)
void removeTextPlugin(MD::TextPlugin id)

Detailed Description

Parser of Markdown.

Member Function Documentation

Parser::Parser()

Default constructor.

GitHub's autolinks extension will be added by default.

void Parser::addBlockPlugin(std::shared_ptr<MD::BlockPlugin<Trait>> plugin)

Add block plugin.

plugin Plugin.

void Parser::addTextPlugin(MD::TextPlugin id, MD::TextPluginFunc<Trait> plugin, bool processInLinks, const typename Trait::StringList &userData)

Add text plugin.

id ID of a plugin. Use TextPlugin::TextPlugin::UserDefined value for start ID.

plugin Function of a plugin, that will be invoked to processs raw text.

processInLinks Should this plugin be used in parsing of internals of links?

userData User data that will be passed to plugin function.

std::shared_ptr<MD::Document<Trait>> Parser::parse(const typename Trait::String &fileName, bool recursive = true, const typename Trait::StringList &ext = {Trait::latin1ToString("md"), Trait::latin1ToString("markdown")}, bool fullyOptimizeParagraphs = true)

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.

fullyOptimizeParagraphs Make full optimization, or just semi one. In full optimization text items with one style but with some closing delimiters in the middle will be concatenated in one, like in **text* text*, here in full optimization will be "text text" with 2 open/close style delimiters, but one closing delimiter is in the middle.

std::shared_ptr<MD::Document<Trait>> Parser::parse(typename Trait::TextStream &stream, const typename Trait::String &path, const typename Trait::String &fileName, bool fullyOptimizeParagraphs = true)

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.

fullyOptimizeParagraphs Make full optimization, or just semi one. In full optimization text items with one style but with some closing delimiters in the middle will be concatenated in one, like in **text* text*, here in full optimization will be "text text" with 2 open/close style delimiters, but one closing delimiter is in the middle.

std::shared_ptr<MD::Document<Trait>> Parser::parse(const typename Trait::String &fileName, const typename Trait::String &workingDirectory, bool recursive = true, const typename Trait::StringList &ext = {Trait::latin1ToString("md"), Trait::latin1ToString("markdown")}, bool fullyOptimizeParagraphs = true)

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.

fullyOptimizeParagraphs Make full optimization, or just semi one. In full optimization text items with one style but with some closing delimiters in the middle will be concatenated in one, like in **text* text*, here in full optimization will be "text text" with 2 open/close style delimiters, but one closing delimiter is in the middle.

void Parser::removeBlockPlugin(MD::BlockType id)

Remove block plugin.

id ID.

void Parser::removeTextPlugin(MD::TextPlugin id)

Remove text plugin.

id ID of plugin that should be removed.