HtmlImport.h header
#include <ew/app/HtmlImport.h>
Namespace ew::app
Functions
QString ew::app::htmlToMarkdown(const QString &html)
Converts an HTML fragment or document html to the app's Markdown subset. <script>, <style>, and <!-- comments --> (with their contents) are dropped; headings become #..######, paragraphs and <br> become line breaks, <ul>/<ol> items become -/1. lists, <strong>/<b> and <em>/<i> become **/*, <a href> becomes [text](href), <blockquote> becomes > lines, <hr> becomes ---, <pre>/<code> become fenced/inline code, and <table> becomes a GFM pipe table. Named and numeric HTML entities are decoded and runs of blank lines are collapsed. Unknown tags are dropped but their text is kept. Pure and GUI-free (mirrors the export side's hand-rolled markdownToHtml).
ImportedManuscript ew::app::importHtml(const QString &html, const QString &title)
Imports html as a prose manuscript titled title: the HTML is converted to Markdown (see htmlToMarkdown) and split into a document tree at the shallowest heading level via splitMarkdownIntoTree(..., 0). Empty input yields a single empty root document.
ImportedManuscript ew::app::splitMarkdownIntoTree(const QString &markdown, const QString &title, int splitLevel)
Splits already-Markdown markdown into a prose document tree titled title, controlled by splitLevel: negative = do not split (one root Document carrying the whole body); 0 = auto (split at the shallowest heading level present, h1 else h2 …; no headings ⇒ one document); 1..6 = split at exactly that heading level. Each split-point heading becomes a child Document titled by the heading text, its body the Markdown from that heading to the next same-level heading (deeper sub-headings stay inline); content before the first split heading becomes the root's body. The root's parentId is null and each child's parentId is the root's id, ordered by sortIndex — matching ImportedManuscript's contract.