PlainTextImport.h header
#include <ew/app/PlainTextImport.h>
Namespace ew::app
ImportedManuscript struct
struct ew::app::ImportedManuscript
The documents produced by importing plain text: a root document followed by its child scene documents (empty of children when the text is a single scene, in which case the root carries the whole body). The root's parentId is null; each child's parentId is the root's id, and children are ordered by sortIndex. Documents are returned by pointer because content objects are non-copyable.
Members
std::vector<std::unique_ptr<ew::core::document::Document> > ew::app::import::ImportedManuscript::documents
The root document followed by its child scene documents (see the struct description).
Enumerations
enum class SourceFormat { PlainText, Markdown }
What the text being imported already is, which decides whether it needs escaping before it is stored as a Markdown body.
Functions
ImportedManuscript ew::app::import::importPlainText(const QString &text, const QString &title, SourceFormat format)
Parses plain text into a prose manuscript titled title. Line endings are normalised; the text is split into scenes on scene-break lines – a line whose trimmed form is three or more separator characters (any of * - _ = ~ # . · • —), optionally spaced, e.g. "* * *", "---", or "###". Blank scenes are dropped. With two or more scenes, a root Document (of kind Prose, titled title, empty body) is returned with one child Document per scene – each titled from its first non-empty line (trimmed to a sensible length) or "Scene N", parented to the root and ordered by sortIndex. With a single scene, only the root Document is returned, carrying the whole (trimmed) body. Empty or whitespace-only input yields a single empty root document.
format says what the text already is. Bodies are stored as Markdown, so text that is NOT Markdown must be escaped on the way in or the store reinterprets it – see ew::app::document::plainTextAsMarkdown. There is no default: every caller knows which file it opened, and getting it wrong either mangles prose or defeats a writer's real Markdown.