MD::EmphasisParser Class

class MD::EmphasisParser

Emphasis parser. More...

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

MD::AsteriskEmphasisParser and MD::StrikethroughEmphasisParser

Public Functions

virtual MD::ItemWithOpts::Styles closeStyles(qsizetype startPos, qsizetype lineNumber, qsizetype length) const = 0
virtual bool isEmphasis(int length) const = 0
virtual bool isLeftFlanking(const QChar &before, const QChar &after) const
virtual bool isLengthCorrespond() const = 0
virtual bool isRightFlanking(const QChar &before, const QChar &after) const
virtual MD::ItemWithOpts::Styles openStyles(qsizetype startPos, qsizetype lineNumber, qsizetype length) const = 0
virtual const QChar &symbol() const = 0

Reimplemented Public Functions

virtual bool check(MD::Line &line, MD::ParagraphStream &stream, MD::InlineContext &ctx, QSharedPointer<MD::Document> doc, const QString &path, const QString &fileName, QStringList &linksToParse, MD::Parser &parser, const MD::ReverseSolidusHandler &rs) override
virtual QString startDelimiterSymbols() const override

Static Public Members

void processEmphasises(MD::InlineContext &ctx)

Protected Functions

bool isUnicodeWhitespace(const QChar &ch) const

Detailed Description

Emphasis parser. May be reused for any kind of emphasis parsing.

Member Function Documentation

[override virtual] bool EmphasisParser::check(MD::Line &line, MD::ParagraphStream &stream, MD::InlineContext &ctx, QSharedPointer<MD::Document> doc, const QString &path, const QString &fileName, QStringList &linksToParse, MD::Parser &parser, const MD::ReverseSolidusHandler &rs)

Reimplements: InlineParser::check(MD::Line &line, MD::ParagraphStream &stream, MD::InlineContext &ctx, QSharedPointer<MD::Document> doc, const QString &path, const QString &fileName, QStringList &linksToParse, MD::Parser &parser, const MD::ReverseSolidusHandler &rs).

Check if current character (string) is handled by this parser.

Returns true if handled, false otherwise.

This method should do a work with context and handle his delimiters and cache in context ready for use object that will be placed into MD::Paragraph.

line Current line.

stream Stream.

ctx Context.

doc Document.

path Path to Markdown file.

fileName File name of the Markdown file.

linksToParse List of links for further parsing.

parser Parser.

rs Auxiliary struct for checking if first charcter is escaped.

[pure virtual] MD::ItemWithOpts::Styles EmphasisParser::closeStyles(qsizetype startPos, qsizetype lineNumber, qsizetype length) const

Returns closing text option (style) for the given delimiter with the given length.

startPos Start position of the first delimiter.

lineNumber Line number.

length Length of the delimiter.

[pure virtual] bool EmphasisParser::isEmphasis(int length) const

Returns whether the sequence of the given length is an emphasis.

length Length of the sequence.

[virtual] bool EmphasisParser::isLeftFlanking(const QChar &before, const QChar &after) const

Returns whether the given sequence of delimiters is a left flanking.

before Symbol before the sequence, or null character if it's a beginning of a line.

after Symbol after the sequence, or null character if it's an end of a line.

[pure virtual] bool EmphasisParser::isLengthCorrespond() const

Returns whether length of opening and closing delimiter should be equal to each other, or may differ.

[virtual] bool EmphasisParser::isRightFlanking(const QChar &before, const QChar &after) const

Returns whether the given sequence of delimiters is a right flanking.

before Symbol before the sequence, or null character if it's a beginning of a line.

after Symbol after the sequence, or null character if it's an end of a line.

[protected] bool EmphasisParser::isUnicodeWhitespace(const QChar &ch) const

Returns whether Unicode whitespace?

ch Character to check.

[pure virtual] MD::ItemWithOpts::Styles EmphasisParser::openStyles(qsizetype startPos, qsizetype lineNumber, qsizetype length) const

Returns opening text option (style) for the given delimiter with the given length.

startPos Start position of the first delimiter.

lineNumber Line number.

length Length of the delimiter.

[static] void EmphasisParser::processEmphasises(MD::InlineContext &ctx)

Calculate all emphasises in context dropping that the text.

ctx Inline context.

[override virtual] QString EmphasisParser::startDelimiterSymbols() const

Reimplements: InlineParser::startDelimiterSymbols() const.

Returns string with all symbols that can start this kind of inline.

[pure virtual] const QChar &EmphasisParser::symbol() const

Returns delimiter character for this kind of emphasis.