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

class Anchor
class Block
class Blockquote
class Code
class Document
class Footnote
class FootnoteRef
class Heading
class HorizontalLine
class Image
class InternalStringT
class Item
class ItemWithOpts
class LineBreak
class Link
class LinkBase
class List
class ListItem
class Math
struct MdBlock
struct MdLineData
class PageBreak
class Paragraph
class Parser
class PosCache
struct QStringTrait
class RawHtml
struct RawHtmlBlock
class StringListStream
class StyleDelim
class Table
class TableCell
class TableRow
class Text
struct TextParsingOpts
class UnicodeChar
class UnicodeString
struct UnicodeStringTrait
class Visitor
class WithPosition

Types

ItemFunctor
enum class ItemType { Heading, Text, Paragraph, LineBreak, Blockquote, …, UserDefined }
enum class OptimizeParagraphType { Full, Semi, FullWithoutRawData, SemiWithoutRawData }
enum class Style { Italic1, Italic2, Bold1, Bold2, Strikethrough, Unknown }
enum TextOption { TextWithoutFormat, BoldText, ItalicText, StrikethroughText }
enum TextPlugin { UnknownPluginID, GitHubAutoLinkPluginID, UserDefinedPluginID }
TextPluginFunc
TextPluginsMap

Variables

const char *s_startComment

Functions

void appendCloseStyle(MD::TextParsingOpts<Trait> &po, const MD::StyleDelim &s)
void applyStyles(int &opts, std::vector<typename TextParsingOpts<Trait>::StyleInfo> &styles)
std::pair<long long, long long> calculateIndent(const typename Trait::String &s, long long p)
bool checkForEndHtmlComments(const typename Trait::String &line, long long pos)
void checkForHtmlComments(const typename Trait::InternalString &line, MD::StringListStream<Trait> &stream, MD::MdLineData::CommentDataMap &res)
void checkForTableInParagraph(MD::TextParsingOpts<Trait> &po, long long lastLine)
void checkForTextPlugins(std::shared_ptr<MD::Paragraph<Trait>> p, MD::TextParsingOpts<Trait> &po, const MD::TextPluginsMap<Trait> &textPlugins, bool inLink)
void closeStyle(std::vector<typename TextParsingOpts<Trait>::StyleInfo> &styles, MD::Style s)
std::shared_ptr<MD::Text<Trait>> concatenateText(typename Block<Trait>::Items::const_iterator it, typename Block<Trait>::Items::const_iterator last)
void eatRawHtml(long long line, long long pos, long long toLine, long long toPos, MD::TextParsingOpts<Trait> &po, bool finish, int htmlRule, bool onLine, bool continueEating = false)
MD::WithPosition findAndRemoveClosingSequence(typename Trait::InternalString &s)
std::pair<typename Trait::String, MD::WithPosition> findAndRemoveHeaderLabel(typename Trait::InternalString &s)
void forEach(const typename Trait::template Vector<ItemType> &types, std::shared_ptr<MD::Document<Trait>> doc, MD::ItemFunctor<Trait> func, unsigned int maxNestingLevel = 0)
void githubAutolinkPlugin(std::shared_ptr<MD::Paragraph<Trait>> p, MD::TextParsingOpts<Trait> &po, const typename Trait::StringList &)
bool indentInList(const std::vector<long long> *indents, long long indent, bool codeIndentedBySpaces)
void initLastItemWithOpts(MD::TextParsingOpts<Trait> &po, std::shared_ptr<MD::ItemWithOpts<Trait>> item)
bool isH1(const typename Trait::String &s)
bool isH2(const typename Trait::String &s)
bool isCodeFences(const typename Trait::String &s, bool closing = false)
bool isColumnAlignment(const typename Trait::String &s)
bool isEmail(const typename Trait::String &url)
bool isFootnote(const typename Trait::String &s)
bool isGitHubAutolink(const typename Trait::String &url)
bool isH(const typename Trait::String &s, const typename Trait::Char &c)
bool isHorizontalLine(const typename Trait::String &s)
bool isHtmlComment(const typename Trait::String &s)
std::tuple<bool, long long, long long, bool, typename Trait::String> isHtmlTag(long long line, long long pos, MD::TextParsingOpts<Trait> &po, int rule)
bool isLineBreak(const typename Trait::String &s)
bool isListItemAndNotNested(const typename Trait::String &s, long long indent)
bool isOnlyHtmlTagsAfterOrClosedRule1(long long line, long long pos, MD::TextParsingOpts<Trait> &po, int rule)
bool isOrderedList(const typename Trait::String &s, int *num = nullptr, int *len = nullptr, typename Trait::Char *delim = nullptr, bool *isFirstLineEmpty = nullptr)
bool isSemiOptimization(MD::OptimizeParagraphType t)
bool isSetextHeadingBetween(const MD::TextParsingOpts<Trait> &po, long long startLine, long long endLine)
bool isStartOfCode(const typename Trait::String &str, typename Trait::String *syntax = nullptr, MD::WithPosition *delim = nullptr, MD::WithPosition *syntaxPos = nullptr)
int isTableAlignment(const typename Trait::String &s)
int isTableHeader(const typename Trait::String &s)
bool isValidUrl(const typename Trait::String &url)
bool isWithoutRawDataOptimization(MD::OptimizeParagraphType t)
long long lastNonSpacePos(const String &line)
long long lastVirginPositionInParagraph(MD::Item<Trait> *item)
long long lineBreakLength(const typename Trait::String &s)
std::tuple<bool, long long, typename Trait::Char, bool> listItemData(const typename Trait::String &s, bool wasText)
long long listLevel(const std::vector<long long> &indents, long long pos)
std::pair<long long, long long> localPosFromVirgin(const MD::MdBlock<Trait> &fr, long long virginColumn, long long virginLine)
void makeHeading(std::shared_ptr<MD::Block<Trait>> parent, std::shared_ptr<MD::Document<Trait>> doc, std::shared_ptr<MD::Paragraph<Trait>> p, long long lastColumn, long long lastLine, int level, const typename Trait::String &workingPath, const typename Trait::String &fileName, bool collectRefLinks, const MD::WithPosition &delim, MD::TextParsingOpts<Trait> &po)
void makeHorLine(const typename MdBlock<Trait>::Line &line, std::shared_ptr<MD::Block<Trait>> parent)
std::shared_ptr<MD::Paragraph<Trait>> makeParagraph(typename Block<Trait>::Items::const_iterator first, typename Block<Trait>::Items::const_iterator last)
void makeText(long long lastLine, long long lastPos, MD::TextParsingOpts<Trait> &po)
void makeTextObject(const typename Trait::String &text, MD::TextParsingOpts<Trait> &po, long long startPos, long long startLine, long long endPos, long long endLine, bool doRemoveSpacesAtEnd = false)
void makeTextObjectWithLineBreak(const typename Trait::String &text, MD::TextParsingOpts<Trait> &po, long long startPos, long long startLine, long long endPos, long long endLine)
std::pair<long long, long long> nextPosition(const MD::MdBlock<Trait> &fr, long long pos, long long line)
void normalizePos(long long &pos, long long &line, long long length, long long linesCount)
std::shared_ptr<MD::Paragraph<Trait>> optimizeParagraph(std::shared_ptr<MD::Paragraph<Trait>> &p, MD::TextParsingOpts<Trait> &po, MD::OptimizeParagraphType type = OptimizeParagraphType::Full)
typename Trait::String paragraphToLabel(MD::Paragraph<Trait> *p)
long long posOfListItem(const typename Trait::String &s, bool ordered)
typename Trait::InternalString prepareTableData(typename Trait::InternalString s)
std::pair<long long, long long> prevPosition(const MD::MdBlock<Trait> &fr, long long pos, long long line)
long long processGitHubAutolinkExtension(std::shared_ptr<MD::Paragraph<Trait>> p, MD::TextParsingOpts<Trait> &po, long long idx)
typename Trait::String readEscapedSequence(long long i, const typename Trait::String &str, long long *endPos = nullptr)
std::pair<bool, bool> readHtmlAttr(long long &l, long long &p, const typename MdBlock<Trait>::Data &fr, bool checkForSpace)
std::pair<bool, bool> readHtmlAttrValue(long long &l, long long &p, const typename MdBlock<Trait>::Data &fr)
std::tuple<long long, long long, bool, typename Trait::String, long long> readLinkDestination(long long line, long long pos, const MD::TextParsingOpts<Trait> &po, MD::WithPosition *urlPos = nullptr)
std::tuple<long long, long long, bool, typename Trait::String, long long> readLinkTitle(long long line, long long pos, const MD::TextParsingOpts<Trait> &po)
std::pair<bool, bool> readUnquotedHtmlAttrValue(long long &l, long long &p, const typename MdBlock<Trait>::Data &fr)
String removeBackslashes(const String &s)
typename MdBlock<Trait>::Data removeBackslashes(const typename MdBlock<Trait>::Data &d)
typename Trait::String removeLineBreak(const typename Trait::String &s)
void removeSpacesAtEnd(String &s)
typename Trait::String replaceEntity(const typename Trait::String &s)
void replaceTabs(typename Trait::InternalString &s)
void resetHtmlTag(MD::RawHtmlBlock<Trait> &html, MD::TextParsingOpts<Trait> *po = nullptr)
void resolveLinks(typename Trait::StringList &linksToParse, std::shared_ptr<MD::Document<Trait>> doc)
void setLastPos(std::shared_ptr<MD::Item<Trait>> item, long long pos, long long line)
long long skipSpaces(long long i, const typename Trait::String &line)
void skipSpacesInHtml(long long &l, long long &p, const typename MdBlock<Trait>::Data &fr)
void skipSpacesUpTo1Line(long long &line, long long &pos, const typename MdBlock<Trait>::Data &fr)
std::shared_ptr<MD::Paragraph<Trait>> splitParagraphsAndFreeHtml(std::shared_ptr<MD::Block<Trait>> parent, std::shared_ptr<MD::Paragraph<Trait>> p, MD::TextParsingOpts<Trait> &po, bool collectRefLinks, bool fullyOptimizeParagraphs = true)
typename Trait::StringList splitString(const typename Trait::String &str, const typename Trait::Char &ch)
std::pair<typename Trait::InternalStringList, std::vector<long long>> splitTableRow(const typename Trait::InternalString &s)
typename Trait::String startSequence(const typename Trait::String &line)
typename Trait::String stringToLabel(const typename Trait::String &s)
MD::TextOption styleToTextOption(MD::Style s)
long long textAtIdx(std::shared_ptr<MD::Paragraph<Trait>> p, size_t idx)
typename Trait::String toHtml(std::shared_ptr<MD::Document<Trait>> doc, bool wrapInBodyTag = true, const typename Trait::String &hrefForRefBackImage = {}, bool wrapInArticle = true)
void updateLastPosInList(const MD::RawHtmlBlock<Trait> &html)
typename Trait::String virginSubstr(const MD::MdBlock<Trait> &fr, const MD::WithPosition &virginPos)
bool operator==(const MD::StyleDelim &l, const MD::StyleDelim &r)
bool operator==(const MD::WithPosition &l, const MD::WithPosition &r)

Macros

Detailed Description

Namespaces

namespace MD::details

Classes

class Anchor

Just an anchor. More...

class Block

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

class Blockquote

Blockquote. More...

class Code

Code. More...

class Document

Document. More...

class Footnote

Footnote. More...

class FootnoteRef

Footnote reference. More...

class Heading

Heading. More...

class HorizontalLine

Horizontal line. More...

class Image

Image. More...

class InternalStringT

Internal string, used to get virgin (original) string from transformed string. More...

class Item

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

class ItemWithOpts

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

class LineBreak

Line break. More...

class Link

Link. More...

class LinkBase

Base class for links. More...

class List

List. More...

class ListItem

List item in a list. More...

class Math

LaTeX math expression. More...

class MdBlock

Internal structure for block of text in Markdown. More...

class MdLineData

Internal structure for auxiliary information about a line in Markdown. More...

class PageBreak

Page break. More...

class Paragraph

Paragraph. More...

class Parser

Markdown parser. More...

class PosCache

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

class QStringTrait

Trait to use this library with QString. More...

class RawHtml

Raw HTML. More...

class RawHtmlBlock

Internal structure for pre-storing HTML. More...

class StringListStream

Wrapper for typename Trait::StringList to be behaved like a stream. More...

class StyleDelim

Emphasis in the Markdown document. More...

class Table

Table. More...

class TableCell

Table cell. More...

class TableRow

Table row. More...

class Text

Text item in Paragraph. More...

class TextParsingOpts

Internal structure for auxiliary options for parser. More...

class UnicodeChar

Wrapper for UChar32 to be used with MD::Parser. More...

class UnicodeString

Wrapper for icu::UnicodeString to be used with MD::Parser. More...

class UnicodeStringTrait

Trait to use this library with std::string. More...

class Visitor

Visitor interface to walk through Document. More...

class WithPosition

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

Type Documentation

[alias] template <typename Trait> 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::OptimizeParagraphType

Type of the paragraph's optimization.

ConstantValueDescription
MD::OptimizeParagraphType::Full0Full optimization.
MD::OptimizeParagraphType::Semi1Semi optimization, optimization won't concatenate text items if style delimiters will be in the middle.
MD::OptimizeParagraphType::FullWithoutRawData2Full optimization, but raw text data won't be concatenated (will be untouched).
MD::OptimizeParagraphType::SemiWithoutRawData3Semi optimization, but raw text data won't be concatenated (will be untouched).

enum class MD::Style

Emphasis type.

ConstantValueDescription
MD::Style::Italic10"*".
MD::Style::Italic21"_".
MD::Style::Bold12"**".
MD::Style::Bold23"__".
MD::Style::Strikethrough4"~".
MD::Style::Unknown5Unknown.

enum MD::TextOption

Text option.

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

enum MD::TextPlugin

ID of text plugin.

ConstantValueDescription
MD::UnknownPluginID0Unknown plugin.
MD::GitHubAutoLinkPluginID1GitHub's autolinks plugin.
MD::UserDefinedPluginID255First user defined plugin ID.

[alias] template <typename Trait> MD::TextPluginFunc

Functor type for text plugin.

[alias] template <typename Trait> MD::TextPluginsMap

Type of the map of text plugins.

Variable Documentation

const char *MD::s_startComment

Starting HTML comment string.

Function Documentation

template <typename Trait> void MD::appendCloseStyle(MD::TextParsingOpts<Trait> &po, const MD::StyleDelim &s)

Append close style.

po Parsing options to append closing style.

s New closing style.

template <typename Trait> void MD::applyStyles(int &opts, std::vector<typename TextParsingOpts<Trait>::StyleInfo> &styles)

Apply styles.

opts Receiver of styles.

styles List of previous (known) styles.

template <typename Trait> std::pair<long long, long long> MD::calculateIndent(const typename Trait::String &s, long long p)

Returns indent.

s String for calculating.

p Start text position.

template <typename Trait> bool MD::checkForEndHtmlComments(const typename Trait::String &line, long long pos)

Returns whether HTML comment closed?

line String for checking.

pos Start position.

template <typename Trait> void MD::checkForHtmlComments(const typename Trait::InternalString &line, MD::StringListStream<Trait> &stream, MD::MdLineData::CommentDataMap &res)

Collect information about HTML comments.

line String for checking.

stream Stream of lines.

res Receiver of information.

template <typename Trait> void MD::checkForTableInParagraph(MD::TextParsingOpts<Trait> &po, long long lastLine)

Check for table in paragraph.

po Text parsing options.

lastLine Last checked line number.

template <typename Trait> void MD::checkForTextPlugins(std::shared_ptr<MD::Paragraph<Trait>> p, MD::TextParsingOpts<Trait> &po, const MD::TextPluginsMap<Trait> &textPlugins, bool inLink)

Process text plugins.

p Paragraph.

po Text parsing options.

textPlugins Map of plugins.

inLink Are we processing link?

template <typename Trait> void MD::closeStyle(std::vector<typename TextParsingOpts<Trait>::StyleInfo> &styles, MD::Style s)

Close style.

styles List of previous (known) styles.

s Style to close.

template <typename Trait> std::shared_ptr<MD::Text<Trait>> MD::concatenateText(typename Block<Trait>::Items::const_iterator it, typename Block<Trait>::Items::const_iterator last)

Concatenate texts in block.

it Start iterator.

last Last iterator.

template <typename Trait> void MD::eatRawHtml(long long line, long long pos, long long toLine, long long toPos, MD::TextParsingOpts<Trait> &po, bool finish, int htmlRule, bool onLine, bool continueEating = false)

Read HTML data.

line Start line number.

pos Start text position.

toLine End line number.

toPos End text position.

po Text parsing options.

finish Should HTML be finished?

htmlRule HTML Markdown rule number.

onLine Is this HTML on-line.

continueEating Is this invocation a continue reading of previous not fully read HTML?

template <typename Trait> MD::WithPosition MD::findAndRemoveClosingSequence(typename Trait::InternalString &s)

Find and remove closing sequence of "#" in heading.

s String for modifications.

template <typename Trait> std::pair<typename Trait::String, MD::WithPosition> MD::findAndRemoveHeaderLabel(typename Trait::InternalString &s)

Find and remove heading label.

s String for modifications.

template <typename Trait> void MD::forEach(const typename Trait::template Vector<ItemType> &types, std::shared_ptr<MD::Document<Trait>> doc, MD::ItemFunctor<Trait> 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...

template <typename Trait> void MD::githubAutolinkPlugin(std::shared_ptr<MD::Paragraph<Trait>> p, MD::TextParsingOpts<Trait> &po, const typename Trait::StringList &)

GitHub autolinks plugin.

p Paragraph.

po Text parsing options.

bool MD::indentInList(const std::vector<long long> *indents, long long indent, bool codeIndentedBySpaces)

Returns whether indent indent belongs to list with previous indents indents.

indents Already known previous indents in list.

indent Indent to check whether it belongs to list.

codeIndentedBySpaces If this flag is false will check if indent indent bounds to right edge of 3 more spaces to existing indent in list, i.e. indent in list if it equal to already known indent or not more of known indent + 3. If this flag is true right edge won't be checked.

template <typename Trait> void MD::initLastItemWithOpts(MD::TextParsingOpts<Trait> &po, std::shared_ptr<MD::ItemWithOpts<Trait>> item)

Initialize item with style information and set it as last item.

po Text parsing options.

item Item to process.

template <typename Trait> bool MD::isH1(const typename Trait::String &s)

Returns whether the given string a heading's service sequence of level 1?

s String for checking.

template <typename Trait> bool MD::isH2(const typename Trait::String &s)

Returns whether the given string a heading's service sequence of level 2?

s String for checking.

template <typename Trait> bool MD::isCodeFences(const typename Trait::String &s, bool closing = false)

Returns whether string a code fences?

s String for checking.

closing Flag telling that check should be done for closing code fences.

template <typename Trait> bool MD::isColumnAlignment(const typename Trait::String &s)

Returns whether string a column alignment?

s String for checking.

template <typename Trait> bool MD::isEmail(const typename Trait::String &url)

Returns whether the given string a valid email?

url String for checking.

template <typename Trait> bool MD::isFootnote(const typename Trait::String &s)

Returns whether string a footnote?

s String for checking.

Returns whether the given string a GitHub autolink?

url String for checking.

template <typename Trait> bool MD::isH(const typename Trait::String &s, const typename Trait::Char &c)

Returns whether the given string a heading's service sequence?

s String for checking.

c Character of heading's sequence.

template <typename Trait> bool MD::isHorizontalLine(const typename Trait::String &s)

Returns whether string a horizontal line?

s String for checking.

template <typename Trait> bool MD::isHtmlComment(const typename Trait::String &s)

Returns whether given string a HTML comment.

s String for checking.

template <typename Trait> std::tuple<bool, long long, long long, bool, typename Trait::String> MD::isHtmlTag(long long line, long long pos, MD::TextParsingOpts<Trait> &po, int rule)

Returns whether HTML tag at the given position?

line Start line number.

pos Start text position.

po Text parsing options.

rule HTML Markdown rule number.

template <typename Trait> bool MD::isLineBreak(const typename Trait::String &s)

Returns whether the given string a line break.

s String for checking.

template <typename Trait> bool MD::isListItemAndNotNested(const typename Trait::String &s, long long indent)

Returns whether the given string a new list item.

s String for checking.

indent Indent for checking.

template <typename Trait> bool MD::isOnlyHtmlTagsAfterOrClosedRule1(long long line, long long pos, MD::TextParsingOpts<Trait> &po, int rule)

Returns whether after the given position only HTML tags?

line Start line number.

pos Start text position.

po Text parsing options.

rule HTML Markdown rule number.

template <typename Trait> bool MD::isOrderedList(const typename Trait::String &s, int *num = nullptr, int *len = nullptr, typename Trait::Char *delim = nullptr, bool *isFirstLineEmpty = nullptr)

Returns whether string an ordered list.

s String for checking.

num Receiver of integer value of ordered list.

len Receiver of number of characters in ordered list integer value.

delim Receiver of delimiter character ("." or ")").

isFirstLineEmpty Receiver of boolean value representing that there is no text other than spaces after ordered list marker.

bool MD::isSemiOptimization(MD::OptimizeParagraphType t)

Returns whether optimization type a semi one.

t Paragraph optimization type.

template <typename Trait> bool MD::isSetextHeadingBetween(const MD::TextParsingOpts<Trait> &po, long long startLine, long long endLine)

Returns whether setext heading in the lines?

po Text parsing options.

startLine Start line number.

endLine End line number.

template <typename Trait> bool MD::isStartOfCode(const typename Trait::String &str, typename Trait::String *syntax = nullptr, MD::WithPosition *delim = nullptr, MD::WithPosition *syntaxPos = nullptr)

Returns whether string a start of code?

str String for checking.

syntax Receiver of syntax string.

delim Receiver of position of code fences start sequence.

syntaxPos Receiver of position of syntax string.

template <typename Trait> int MD::isTableAlignment(const typename Trait::String &s)

Returns number of columns?

s String for checking.

template <typename Trait> int MD::isTableHeader(const typename Trait::String &s)

Returns number of columns in table, if the given string is a table header.

s String for checking.

template <typename Trait> bool MD::isValidUrl(const typename Trait::String &url)

Returns whether the fiven string a valid URL?

url String for checking.

bool MD::isWithoutRawDataOptimization(MD::OptimizeParagraphType t)

Returns whether optimization type without raw data optimization?

t Paragraph optimization type.

template <typename String> long long MD::lastNonSpacePos(const String &line)

Returns last non-space character position.

line String where to find last non-space character position.

template <typename Trait> long long MD::lastVirginPositionInParagraph(MD::Item<Trait> *item)

Returns last virgin position of the item.

item Item.

template <typename Trait> long long MD::lineBreakLength(const typename Trait::String &s)

Returns length of line break.

s String for checking.

template <typename Trait> std::tuple<bool, long long, typename Trait::Char, bool> MD::listItemData(const typename Trait::String &s, bool wasText)

Returns list item data.

s String for checking.

wasText Was a text before?

long long MD::listLevel(const std::vector<long long> &indents, long long pos)

Returns level in indents for the given position.

indents List of known indents.

pos Position for checking.

template <typename Trait> std::pair<long long, long long> MD::localPosFromVirgin(const MD::MdBlock<Trait> &fr, long long virginColumn, long long virginLine)

Returns local position ( { column, line } ) in fragment for given virgin position if exists. Returns { -1, -1 } if there is no given position.

fr Text fragment (list of lines).

virginColumn Virgin position of character.

virginLine Virgin line number.

template <typename Trait> void MD::makeHeading(std::shared_ptr<MD::Block<Trait>> parent, std::shared_ptr<MD::Document<Trait>> doc, std::shared_ptr<MD::Paragraph<Trait>> p, long long lastColumn, long long lastLine, int level, const typename Trait::String &workingPath, const typename Trait::String &fileName, bool collectRefLinks, const MD::WithPosition &delim, MD::TextParsingOpts<Trait> &po)

Make heading.

parent Receiver of heading.

doc Document.

p Paragraph of heading.

lastColumn Last virgin position of heading.

lastLine Last virgin line number of heading.

level Level number of heading.

workingPath Working directory for this Markdown file.

fileName File name of this Markdown file.

collectRefLinks Are we collecting reference links?

delim Heading's delimiter position.

po Text parsing options.

template <typename Trait> void MD::makeHorLine(const typename MdBlock<Trait>::Line &line, std::shared_ptr<MD::Block<Trait>> parent)

Make horizontal line.

line Line in text fragment.

parent Receiver of horizontal line.

template <typename Trait> std::shared_ptr<MD::Paragraph<Trait>> MD::makeParagraph(typename Block<Trait>::Items::const_iterator first, typename Block<Trait>::Items::const_iterator last)

Make Paragraph.

first First iterator.

last Last iterator.

template <typename Trait> void MD::makeText(long long lastLine, long long lastPos, MD::TextParsingOpts<Trait> &po)

Make text item.

lastLine Last line number. Inclusive. Don't pass lastLine > actual line position with 0 lastPos. Pass as is, i.e. if line length is 18 and you need whole line then pass lastLine = index of line, and lastPos = 18, or you may crash here if you will pass lastLine = index of line + 1 and lastPos = 0...

lastPos Last text position. Not inclusive.

po Text parsing options.

template <typename Trait> void MD::makeTextObject(const typename Trait::String &text, MD::TextParsingOpts<Trait> &po, long long startPos, long long startLine, long long endPos, long long endLine, bool doRemoveSpacesAtEnd = false)

Make text item.

text Text.

po Text parsing options.

startPos Start text position.

startLine Start line number.

endPos End text position.

endLine End line number.

doRemoveSpacesAtEnd Should spaces at end of text be removed?

template <typename Trait> void MD::makeTextObjectWithLineBreak(const typename Trait::String &text, MD::TextParsingOpts<Trait> &po, long long startPos, long long startLine, long long endPos, long long endLine)

Make text item with line break.

text Text.

po Text parsing options.

startPos Start text position.

startLine Start line number.

endPos End text position.

endLine End line number.

template <typename Trait> std::pair<long long, long long> MD::nextPosition(const MD::MdBlock<Trait> &fr, long long pos, long long line)

Returns next position in the block.

fr Text fragment (list of lines).

pos Text position.

line Line number.

void MD::normalizePos(long long &pos, long long &line, long long length, long long linesCount)

Normalize position.

pos Text position.

line Line number.

length Length of string on line line.

linesCount Count of lines in fragment.

template <typename Trait> std::shared_ptr<MD::Paragraph<Trait>> MD::optimizeParagraph(std::shared_ptr<MD::Paragraph<Trait>> &p, MD::TextParsingOpts<Trait> &po, MD::OptimizeParagraphType type = OptimizeParagraphType::Full)

Optimize Paragraph.

p Paragraph.

po Text parsing options.

type Paragraph optimization type.

template <typename Trait> typename Trait::String MD::paragraphToLabel(MD::Paragraph<Trait> *p)

Convert MD::Paragraph to label.

p Paragraph.

template <typename Trait> long long MD::posOfListItem(const typename Trait::String &s, bool ordered)

Returns position of first character in list item.

s String for checking.

ordered A flag whether list is ordered.

template <typename Trait> typename Trait::InternalString MD::prepareTableData(typename Trait::InternalString s)

Prepare data in table cell for parsing.

s String for modifications.

template <typename Trait> std::pair<long long, long long> MD::prevPosition(const MD::MdBlock<Trait> &fr, long long pos, long long line)

Returns previous position in the block.

fr Text fragment (list of lines).

pos Text position.

line Line number

template <typename Trait> long long MD::processGitHubAutolinkExtension(std::shared_ptr<MD::Paragraph<Trait>> p, MD::TextParsingOpts<Trait> &po, long long idx)

Process GitHub autolinks for the text with index idx.

p Paragraph.

po Text parsing options.

idx Index of text (in raw text).

template <typename Trait> typename Trait::String MD::readEscapedSequence(long long i, const typename Trait::String &str, long long *endPos = nullptr)

Skip escaped sequence of characters till first space.

i Start position.

str String for reading.

endPos Receiver of last character's position in sequence.

template <typename Trait> std::pair<bool, bool> MD::readHtmlAttr(long long &l, long long &p, const typename MdBlock<Trait>::Data &fr, bool checkForSpace)

Read HTML attribute.

l Start line number.

p Start text position.

fr Text fragment (list of lines).

checkForSpace Should space exist before HTML attribute?

template <typename Trait> std::pair<bool, bool> MD::readHtmlAttrValue(long long &l, long long &p, const typename MdBlock<Trait>::Data &fr)

Read HTML attribute value.

l Start line number.

p Start text position.

fr Text fragment (list of lines).

template <typename Trait> std::tuple<long long, long long, bool, typename Trait::String, long long> MD::readLinkDestination(long long line, long long pos, const MD::TextParsingOpts<Trait> &po, MD::WithPosition *urlPos = nullptr)

Read link's destination.

line Start line number.

pos Start text position.

po Text parsing options.

urlPos Receiver of URL positions.

template <typename Trait> std::tuple<long long, long long, bool, typename Trait::String, long long> MD::readLinkTitle(long long line, long long pos, const MD::TextParsingOpts<Trait> &po)

Read link's title.

line Start line number.

pos Start text position.

po Text parsing options.

template <typename Trait> std::pair<bool, bool> MD::readUnquotedHtmlAttrValue(long long &l, long long &p, const typename MdBlock<Trait>::Data &fr)

Read HTML attribute value.

l Start line number.

p Start text position.

fr Text fragment (list of lines).

template <typename String, typename Trait> String MD::removeBackslashes(const String &s)

Remove backslashes from the string.

s String for modification.

template <typename Trait> typename MdBlock<Trait>::Data MD::removeBackslashes(const typename MdBlock<Trait>::Data &d)

Remove backslashes in block.

d List of lines where to remove backslashes.

template <typename Trait> typename Trait::String MD::removeLineBreak(const typename Trait::String &s)

Remove line break from the end of string.

s String for modifications.

template <typename String> void MD::removeSpacesAtEnd(String &s)

Remove spaces at the end of string s.

s String where to remove last spaces.

template <typename Trait> typename Trait::String MD::replaceEntity(const typename Trait::String &s)

Replace entities in the string with corresponding character.

s String for modifications.

template <typename Trait> void MD::replaceTabs(typename Trait::InternalString &s)

Replace tabs with spaces (just for internal simpler use).

s String for modifications.

template <typename Trait> void MD::resetHtmlTag(MD::RawHtmlBlock<Trait> &html, MD::TextParsingOpts<Trait> *po = nullptr)

Reset pre-stored HTML.

html Pre-stored HTML to process.

po Optional text parsing options for modifications.

Resolve links in the document.

linksToParse List of links.

doc Document.

template <typename Trait> void MD::setLastPos(std::shared_ptr<MD::Item<Trait>> item, long long pos, long long line)

Set last position of the item.

item Item.

pos Item's last position.

line Item's last line number.

template <typename Trait> long long MD::skipSpaces(long long i, const typename Trait::String &line)

Skip spaces in line from position i.

i Start position for skipping spaces.

line String where to skip spaces.

template <typename Trait> void MD::skipSpacesInHtml(long long &l, long long &p, const typename MdBlock<Trait>::Data &fr)

Skip spaces.

l Start line number.

p Start text position.

fr Text fragment (list of lines).

template <typename Trait> void MD::skipSpacesUpTo1Line(long long &line, long long &pos, const typename MdBlock<Trait>::Data &fr)

Skip space in the block up to 1 new line.

line Start line number.

pos Start text position.

fr Text fragment (list of lines).

template <typename Trait> std::shared_ptr<MD::Paragraph<Trait>> MD::splitParagraphsAndFreeHtml(std::shared_ptr<MD::Block<Trait>> parent, std::shared_ptr<MD::Paragraph<Trait>> p, MD::TextParsingOpts<Trait> &po, bool collectRefLinks, bool fullyOptimizeParagraphs = true)

Split Paragraph and free HTML.

parent Receiver of splitted data.

p Paragraph.

po Text parsing options.

collectRefLinks Are we collecting reference links?

fullyOptimizeParagraphs Should we fully optimize paragraphs?

template <typename Trait> typename Trait::StringList MD::splitString(const typename Trait::String &str, const typename Trait::Char &ch)

Split string.

str String for splitting.

ch Splitting character.

template <typename Trait> std::pair<typename Trait::InternalStringList, std::vector<long long>> MD::splitTableRow(const typename Trait::InternalString &s)

Split table's row on cells.

s String for splitting.

template <typename Trait> typename Trait::String MD::startSequence(const typename Trait::String &line)

Returns starting sequence of the same characters.

line String where to check for starting sequence.

template <typename Trait> typename Trait::String MD::stringToLabel(const typename Trait::String &s)

Convert string to label.

s String for converting.

MD::TextOption MD::styleToTextOption(MD::Style s)

Returns text option from style.

s Style.

template <typename Trait> long long MD::textAtIdx(std::shared_ptr<MD::Paragraph<Trait>> p, size_t idx)

Returns index of text item for the given index in raw text data.

p Paragraph.

idx Index in raw text data.

template <typename Trait, typename HtmlVisitor = MD::details::HtmlVisitor<Trait>> typename Trait::String MD::toHtml(std::shared_ptr<MD::Document<Trait>> doc, bool wrapInBodyTag = true, const typename Trait::String &hrefForRefBackImage = {}, bool wrapInArticle = true)

Convert Document to HTML.

doc Markdown document.

wrapInBodyTag Wrap HTML into <body> tag?

hrefForRefBackImage String that will be applied as URL for image for back link from footnote.

wrapInArticle Wrap HTML with <article> tag?

template <typename Trait> void MD::updateLastPosInList(const MD::RawHtmlBlock<Trait> &html)

Update last position of all parent.

html Pre-stored HTML.

template <typename Trait> typename Trait::String MD::virginSubstr(const MD::MdBlock<Trait> &fr, const MD::WithPosition &virginPos)

Returns substring from fragment with given virgin positions.

fr Text fragment (list of lines).

virginPos Virgin coordinates of text in fragment.

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

Returns whether both are equal.

l Left operand.

r Right operand.

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

Returns whether both are equal.

l Left operand.

r Right operand.

Macro Documentation

MD_DISABLE_COPY

Macro for disabling copy.

MD_UNUSED

Avoid "unused parameter" warnings.