MarkdownHtml.h header
#include <ew/app/MarkdownHtml.h>
Namespace ew::app
Functions
const QString & ew::app::publishing::markdownHrefPattern()
The capturing sub-pattern for the URL inside ](…), for any code that needs to read a Markdown link or image with the same reach the renderer does. It allows one level of balanced parentheses, so en.wikipedia.org/wiki/Mercury_(planet) is captured whole rather than truncated at the first ) – a narrower [^)]+ reads part of the path and strands the rest. The alternation is unambiguous (a non-paren character and a (…) group differ by first character) and the group is possessive (++), so there is no backtracking on a long or unterminated href.
std::vector< QString > ew::app::publishing::markdownImageSources(const QString &markdown)
The src of every Markdown image () in markdown, in order, with duplicates, and unfiltered. It reads images with exactly the grammar markdownToHtml renders them with, so an exporter that packages the files a page references can never disagree with the renderer about which file that is – a path like assets/map(1).png, whose parentheses the renderer carries whole, is returned whole. An image written inside a code span is reported even though it renders as text: over-reporting costs an unused file, while under-reporting leaves a book pointing at a resource it does not contain.
QString ew::app::publishing::markdownLinksToText(const QString &markdown)
markdown with every image and link reduced to its own text –  to its alt text, [label](url) to its label – read with the same grammar markdownToHtml renders. The exports that carry neither a hyperlink nor a picture (Word, standard manuscript) use this so a URL is consumed whole: reading it with a narrower grammar leaves its tail stranded in the prose, which in a submitted manuscript is a stray ) in the middle of a sentence.
QString ew::app::publishing::markdownToHtml(const QString &markdown)
Renders a Markdown document to an HTML fragment (no <html>/<body> wrapper), covering the subset Ordfoss produces and exports: ATX headings (#..######), paragraphs, unordered lists (-/* items), blockquotes (>), horizontal rules (a line of three or more -, *, or _), and inline **bold**, *italic*, `code` ,  images, and [text](url) links. Images emit a self-closing <img/> so the output is valid both as HTML5 and as the XHTML an EPUB requires. All text is HTML-escaped and unrecognised syntax is emitted as escaped text, so the output is safe and clean for themeable export (the website generator, EPUB, HTML export) without pulling in a GUI text engine.