MarkdownBlocks.h header
#include <ew/app/MarkdownBlocks.h>
Namespace ew::app
MarkdownBlock struct
struct ew::app::MarkdownBlock
One block produced by scanMarkdownBlocks. Which members carry meaning depends on kind; the rest are left at their defaults.
Members
MarkdownBlockKind ew::app::publishing::MarkdownBlock::kind =
What this block is.
int ew::app::publishing::MarkdownBlock::level = 0
A heading's depth, 1–6. Meaningless for every other kind.
int ew::app::publishing::MarkdownBlock::indent = 0
A list item's leading indent in characters, which is what drives nesting depth. Meaningless for every other kind.
bool ew::app::publishing::MarkdownBlock::ordered = false
Whether a list item is numbered (1.) rather than bulleted (-).
QString ew::app::publishing::MarkdownBlock::text
The block's text: a heading's title, a list item's or quote line's or paragraph line's content, or a code block's verbatim body. Empty for a rule, a table, and a blank.
QString ew::app::publishing::MarkdownBlock::language
A fenced code block's info string (its language), when it carries one.
QString ew::app::publishing::MarkdownBlock::tableHeader
A table's header row, exactly as written including its pipes.
QString ew::app::publishing::MarkdownBlock::tableDelimiter
A table's delimiter row, which carries the per-column alignment.
QStringList ew::app::publishing::MarkdownBlock::tableRows
A table's body rows, in order.
document::BlockStyleExt ew::app::publishing::MarkdownBlock::blockStyle
The style a {.ew …} line carries, for MarkdownBlockKind::BlockStyle.
Enumerations
enum class MarkdownBlockKind { Blank, Heading, Rule, ListItem, QuoteLine, ParagraphLine, CodeBlock, Table, BlockStyle }
What one scanned block of Markdown is. The scan is line-driven, so a paragraph and a block quote arrive one line at a time (MarkdownBlockKind::ParagraphLine / MarkdownBlockKind::QuoteLine) and a MarkdownBlockKind::Blank ends the run – a renderer decides how to join them, because HTML joins with a space and a page-layout format may not.
Functions
std::vector< MarkdownBlock > ew::app::publishing::scanMarkdownBlocks(const QStringList &lines)
Scans lines as Markdown block structure – the one grammar behind every renderer, so an export format cannot disagree with another about what a line is. Fenced code is taken verbatim (an unterminated fence still yields its block), a GFM table is recognized by a delimiter row under a pipe row and consumed whole, and list items are matched on the raw line so their indent survives. Inline syntax is NOT interpreted: each renderer applies its own, because what a link or an image becomes differs by format.
std::vector< MarkdownBlock > ew::app::publishing::scanMarkdownBlocks(const QString &markdown)
Scans markdown by splitting it into lines first (see scanMarkdownBlocks).
QStringList ew::app::publishing::splitTableCells(const QString &row)
Splits a GFM table row into its trimmed cell texts, honoring the optional outer pipes and backslash-escaped pipes (\|, kept as a literal | inside the cell).
QStringList ew::app::publishing::tableColumnAlignments(const QString &delimiterRow)
The per-column alignment read from a delimiter row's colons: "center" (:-:), "right" (--:), "left" (:--), or empty (no colon). The tokens are the CSS spellings, which Word's w:jc also uses, so both renderers read the same answer.