MD Namespace

Main namespace of md4qt library. More...

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

Namespaces

namespace details

Classes

Types

enum class BlockState { None, Stop, Continue, ContinueWithoutAppendingChildCtx, Discard }
enum class EmphasisSymbol { Unknown, Asterisk, Underline, Tilde, UserDefined }
enum class FensedCodeSymbol { Unknown, Backtick, Tilde }
enum class HeadingType { Unknown, Setext, ATX }
enum class HorizontalLineSymbol { Unknown, Asterisk, Underline, Dash }
ItemFunctor
enum class ItemType { Heading, Text, Paragraph, LineBreak, Blockquote, …, UserDefined }
enum class LineBreakType { Unknown, Spaces, Backslash }
enum class ListItemSymbol { Unknown, Minus, Plus, Asterisk, Dot, Bracket }
enum TextOption { TextWithoutFormat, BoldText, ItalicText, StrikethroughText }

Functions

void forEach(const QVector<MD::ItemType> &types, QSharedPointer<MD::Document> doc, MD::ItemFunctor func, unsigned int maxNestingLevel = 0)
QString getMarkdownContent(MD::ParagraphStream &stream, qsizetype startPos, qsizetype startLine, qsizetype endPos, qsizetype endLine)
int htmlTagRule(MD::Line &line)
qsizetype indentFromColumn(int c)
bool isAsciiControl(const QChar &ch)
bool isAsciiLetter(const QChar &c)
bool isClosed(MD::Line &line, int rule, bool onSameLine)
bool isCommonMarkAutolinkUri(const QString &uri)
bool isEmail(const QString &url)
bool isEmptyLine(MD::Line &line)
bool isHorizontalLine(MD::Line &s)
bool isHtmlTag(const QString &tag, MD::Line &line, bool closed)
bool isIn(const MD::WithPosition &where, const MD::WithPosition &what)
bool isValidTagName(const QString &tag)
bool isValidUrl(const QString &url)
QString readEscapedSequence(MD::Line &line, qsizetype *endPos = nullptr)
bool readHtmlAttrName(MD::Line &line)
bool readHtmlAttrValue(MD::Line &line)
bool readHtmlAttributes(MD::Line &line)
QString readLinkDestination(MD::Line &line)
QString readLinkTitle(MD::Line &line, QChar &startChar, int &startParenthesisCount, qsizetype &startPos, bool &endStarted)
void removeBackslashes(QString &str)
void replaceEntity(QString &str)
void skipIf(MD::Line &line, Pred pred)
qsizetype skipIf(qsizetype startPos, const QString &line, Pred pred, qsizetype endPos = -1)
qsizetype skipIfBackward(qsizetype startPos, const QString &line, Pred pred, qsizetype endPos = -1)
void skipSpaces(MD::Line &line)
QString toHtml(QSharedPointer<MD::Document> doc, bool wrapInBodyTag = true, const QString &footnoteBackLinkContent = {}, bool wrapInArticle = true, const details::IdsMap *idsMap = nullptr)
void writeMultiline(const QString &text, QTextStream &stream, MD::SerialiseHelper *helper)
bool operator<(const MD::StyleDelim &s1, const MD::StyleDelim &s2)
QTextStream &operator<<(QTextStream &stream, const MD::Item &item)
bool operator==(const MD::WithPosition &l, const MD::WithPosition &r)
bool operator==(const MD::StyleDelim &l, const MD::StyleDelim &r)

Detailed Description

All classes and functions of md4qt library is defined in this namespace.

Namespaces

namespace MD::details

Namespace for reusable auxiliary data structures.

Classes

class ATXHeadingParser

ATX heading parser. More...

class Anchor

Just an anchor. More...

class AsteriskEmphasisParser

Asterisk emphasis parser. More...

class AutolinkParser

Autolink parser. More...

class Block

Abstract block (storage of child items). More...

class BlockParser

Base class for parsing a block. More...

class Blockquote

Blockquote. More...

class BlockquoteParser

Blockquote parser. More...

class Code

Code. More...

class Context

Parsing context. More...

class Document

Document. More...

class EmphasisParser

Emphasis parser. More...

class FencedCodeParser

Fenced code parser. More...

class Footnote

Footnote. More...

class FootnoteParser

Footnote parser. More...

class FootnoteRef

Footnote reference. More...

class GfmAutolinkParser

GFM autolink parser. More...

class HTMLParser

HTML block parser. More...

class HardLineBreakParser

Hard line break parser. More...

class Heading

Heading. More...

class HorizontalLine

Horizontal line. More...

class Image

Image. More...

class IndentedCodeParser

Indented code parser. More...

class InlineCodeParser

Inline code parser. More...

class InlineContext

Inline parsing context. More...

class InlineHtmlParser

Inline HTML parser. More...

class InlineMathParser

Inline math parser. More...

class InlineParser

Base class for parsing inlines. More...

class Item

Base class for item in Markdown document. More...

class ItemWithOpts

Base class for items with style options. More...

class Line

Text line in the Markdown input document. More...

class LineBreak

Line break. More...

class Link

Link. More...

class LinkBase

Base class for links. More...

class LinkImageParser

Link and image parser. More...

class List

List. More...

class ListItem

List item in a list. More...

class ListParser

List parser. More...

class Math

LaTeX math expression. More...

class PageBreak

Page break. More...

class Paragraph

Paragraph. More...

class ParagraphParser

Paragraph parser. More...

class ParagraphStream

Text stream for paragraph processing. More...

class Parser

Markdown parser. More...

class PosCache

Cache of Markdown items to be accessed via position. More...

class RawHtml

Raw HTML. More...

class ReverseSolidusHandler

Helper for process reverse solidus characters. More...

class SerialiseHelper

Helper for serialisation. More...

class SetextHeadingParser

Setext heading parser. More...

class StrikethroughEmphasisParser

Strikethrough emphasis parser. More...

class StyleDelim

Emphasis in the Markdown document. More...

class Table

Table. More...

class TableCell

Table cell. More...

class TableParser

Table parser. More...

class TableRow

Table row. More...

class Text

Text item in Paragraph. More...

class TextStream

Actual text stream. More...

class TextStreamBase

Base class for text stream. More...

class ThematicBreakParser

Thematic break parser. More...

class UnderlineEmphasisParser

Underline emphasis parser. More...

class Visitor

Visitor interface to walk through the MD::Document. More...

class WithPosition

Base for any thing with start and end position. More...

class YAMLHeader

YAML header item in the document. More...

class YAMLParser

YAML parser. More...

Type Documentation

enum class MD::BlockState

Enumeration of block parsing states.

ConstantValueDescription
MD::BlockState::None0Means this instance does not handle current line.
MD::BlockState::Stop1Means block was finished and next content should go for parsing of other block.
MD::BlockState::Continue2Means this instance handles this line and parsing should give next lines to this block parser.
MD::BlockState::ContinueWithoutAppendingChildCtx3Means this instance handles this line and parsing should give next lines to this block parser but child context should not be added nor updated.
MD::BlockState::Discard4Used on the next lines after check method to break processing with this block and try to process with other blocks.

enum class MD::EmphasisSymbol

Emphasis symbol.

ConstantValueDescription
MD::EmphasisSymbol::Unknown0Not set.
MD::EmphasisSymbol::Asterisk1Asterisk.
MD::EmphasisSymbol::Underline2Underline.
MD::EmphasisSymbol::Tilde3Tilde.
MD::EmphasisSymbol::UserDefined4User defined.

enum class MD::FensedCodeSymbol

Fensed code symbol.

ConstantValueDescription
MD::FensedCodeSymbol::Unknown0Not set.
MD::FensedCodeSymbol::Backtick1Backtick.
MD::FensedCodeSymbol::Tilde2Tilde.

enum class MD::HeadingType

Heading type.

ConstantValueDescription
MD::HeadingType::Unknown0Not set.
MD::HeadingType::Setext1Setext heading.
MD::HeadingType::ATX2ATX heading.

enum class MD::HorizontalLineSymbol

Horizontal line symbol.

ConstantValueDescription
MD::HorizontalLineSymbol::Unknown0Not set.
MD::HorizontalLineSymbol::Asterisk1Asterisk.
MD::HorizontalLineSymbol::Underline2Underline.
MD::HorizontalLineSymbol::Dash3Dash.

[alias] MD::ItemFunctor

Function type for algorithms.

enum class MD::ItemType

Enumeration of item types.

ConstantValueDescription
MD::ItemType::Heading0Heading.
MD::ItemType::Text1Text.
MD::ItemType::Paragraph2Paragraph.
MD::ItemType::LineBreak3Line break.
MD::ItemType::Blockquote4Blockquote.
MD::ItemType::ListItem5List item.
MD::ItemType::List6List.
MD::ItemType::Link7Link.
MD::ItemType::Image8Image.
MD::ItemType::Code9Code.
MD::ItemType::TableCell10Table cell.
MD::ItemType::TableRow11Table row.
MD::ItemType::Table12Table.
MD::ItemType::FootnoteRef13Footnote ref.
MD::ItemType::Footnote14Footnote.
MD::ItemType::Document15Document.
MD::ItemType::PageBreak16Page break.
MD::ItemType::Anchor17Anchor.
MD::ItemType::HorizontalLine18Horizontal line.
MD::ItemType::RawHtml19Raw HTML.
MD::ItemType::Math20Math expression.
MD::ItemType::UserDefined255Start item for user-defined types.

enum class MD::LineBreakType

Line break type.

ConstantValueDescription
MD::LineBreakType::Unknown0Not set.
MD::LineBreakType::Spaces1Defined with spaces.
MD::LineBreakType::Backslash2Defined with backslash.

enum class MD::ListItemSymbol

List item symbol.

ConstantValueDescription
MD::ListItemSymbol::Unknown0Not set.
MD::ListItemSymbol::Minus1Unorder list item starting with "-".
MD::ListItemSymbol::Plus2Unordered list item starting with "+".
MD::ListItemSymbol::Asterisk3Unordered list item starting with "*".
MD::ListItemSymbol::Dot4Ordered list item starting with ".".
MD::ListItemSymbol::Bracket5Ordered list item starting with ")".

enum MD::TextOption

Text option.

ConstantValueDescription
MD::TextWithoutFormat0No format.
MD::BoldText1Bold text.
MD::ItalicText2Italic text.
MD::StrikethroughText4Strikethrough.

Function Documentation

void MD::forEach(const QVector<MD::ItemType> &types, QSharedPointer<MD::Document> doc, MD::ItemFunctor func, unsigned int maxNestingLevel = 0)

Calls function for each item in the document with the given type.

types Vector of item's types to be processed.

doc Document.

func Functor object.

maxNestingLevel Maximun nesting level. 0 means infinity, 1 - only top level items...

QString MD::getMarkdownContent(MD::ParagraphStream &stream, qsizetype startPos, qsizetype startLine, qsizetype endPos, qsizetype endLine)

Get Markdown string from paragraph stream.

stream Stream.

startPos Start position.

startLine Start line.

endPos End position.

endLine End line.

int MD::htmlTagRule(MD::Line &line)

Returns HTML tag rule.

line Line.

qsizetype MD::indentFromColumn(int c)

Returns indent from column.

c Column.

bool MD::isAsciiControl(const QChar &ch)

Returns whether the give symbol is ASCII control character.

ch Symbol.

bool MD::isAsciiLetter(const QChar &c)

Returns whether the given character is an ASCII letter.

c Character.

bool MD::isClosed(MD::Line &line, int rule, bool onSameLine)

Returns whether the HTML tag was closed.

line Line.

rule HTML tag rule.

onSameLine Flags that check is going on the same line as opening "<" character.

bool MD::isCommonMarkAutolinkUri(const QString &uri)

Returns whether the given string is an absolute URI according to CommonMark's autolink grammar.

uri String for checking.

bool MD::isEmail(const QString &url)

Returns whether the given string a valid email?

url String for checking.

bool MD::isEmptyLine(MD::Line &line)

Return whether the given line is empty starting at the current position.

line Line.

bool MD::isHorizontalLine(MD::Line &s)

Returns whether string a horizontal line?

s String for checking.

bool MD::isHtmlTag(const QString &tag, MD::Line &line, bool closed)

Returns whether the HTML tag was read.

tag HTML tag name.

line Line.

closed Flags whether closing ">" was presented.

bool MD::isIn(const MD::WithPosition &where, const MD::WithPosition &what)

Returns whether the give object is in the given place.

where Place where to check if object is in.

what Object to check.

bool MD::isValidTagName(const QString &tag)

Returns whether the given string a valid HTML tag.

tag String for checking.

bool MD::isValidUrl(const QString &url)

Returns whether the given string a valid URL?

url String for checking.

QString MD::readEscapedSequence(MD::Line &line, qsizetype *endPos = nullptr)

Skip escaped sequence of characters till first space.

line String for reading.

endPos Receiver of last character's position in sequence.

bool MD::readHtmlAttrName(MD::Line &line)

Returns whether the HTML attribute name was read.

line Line.

bool MD::readHtmlAttrValue(MD::Line &line)

Returns whether the HTML attribute value was read.

line Line.

bool MD::readHtmlAttributes(MD::Line &line)

Returns whether the HTML attributes was read.

line Line.

QString MD::readLinkDestination(MD::Line &line)

Read link's destination.

line Line

QString MD::readLinkTitle(MD::Line &line, QChar &startChar, int &startParenthesisCount, qsizetype &startPos, bool &endStarted)

Read link's title.

line Line.

startChar Receiver for surrounding of title character.

startParenthesisCount Receiver for count of start parenthesis.

startPos Receiver for a start position.

endStarted Receiver for flag means that title is ended.

void MD::removeBackslashes(QString &str)

Remove backslashes from string.

str String.

void MD::replaceEntity(QString &str)

Replace entities in the string with corresponding character.

str String for modifications.

template <typename Pred> void MD::skipIf(MD::Line &line, Pred pred)

Skip characters by the given predicate.

line String.

pred Predicate.

template <typename Pred> qsizetype MD::skipIf(qsizetype startPos, const QString &line, Pred pred, qsizetype endPos = -1)

Returns first position of character not satisfying to predicate.

startPos Start position.

line String.

pred Predicate.

endPos End position. -1 means last character in the string.

See also MD::skipIfBackward.

template <typename Pred> qsizetype MD::skipIfBackward(qsizetype startPos, const QString &line, Pred pred, qsizetype endPos = -1)

Returns first position of character not satisfying to predicate moving in backward order.

startPos Start position.

line String.

pred Predicate.

endPos End position. -1 means first character in the string. End position is inclusive.

See also MD::skipIf.

void MD::skipSpaces(MD::Line &line)

Skip space characters.

line String.

template <typename HtmlVisitor = MD::details::HtmlVisitor> QString MD::toHtml(QSharedPointer<MD::Document> doc, bool wrapInBodyTag = true, const QString &footnoteBackLinkContent = {}, bool wrapInArticle = true, const details::IdsMap *idsMap = nullptr)

Convert Document to HTML.

doc Markdown document.

wrapInBodyTag Wrap HTML into <body> tag?

footnoteBackLinkContent String that will be applied as content of back link from footnote. As an example, you can use "<img src="..." />".

wrapInArticle Wrap HTML with <article> tag?

idsMap Map of IDs to set to items.

void MD::writeMultiline(const QString &text, QTextStream &stream, MD::SerialiseHelper *helper)

Serialise multi-lined content.

text Multi-line data.

stream Stream.

helper Serialiser helper.

bool MD::operator<(const MD::StyleDelim &s1, const MD::StyleDelim &s2)

Returns compare state of two style delimiters by theirs positions.

s1 Left operand.

s2 Right operand.

QTextStream &MD::operator<<(QTextStream &stream, const MD::Item &item)

Serialise item into Markdown.

stream Stream.

item Item.

bool operator==(const MD::WithPosition &l, const MD::WithPosition &r)

Returns whether both are equal.

l Left operand.

r Right operand.

bool operator==(const MD::StyleDelim &l, const MD::StyleDelim &r)

Returns whether both are equal.

l Left operand.

r Right operand.