VivoQuant 6.5.0
Loading...
Searching...
No Matches
WorkflowDocument Class Reference

Description

A Workflow Assistant workflow, read from a Markdown file.

Format (GitHub-flavoured Markdown, so it previews correctly in other tools):

  • optional YAML front matter between "---" lines; a title key overrides the heading
  • the first "# Heading" is the workflow title (otherwise the file name)
  • every "## Heading" starts a step; text before the first step becomes an "Overview" step
  • images and links use paths relative to the .md file
  • fenced code blocks with the info string vqs are VivoScript snippets the user can run
  • links to script files (.vqs, .qs, .js) run the script; "?a&b" passes scriptArgs. Absolute paths (S:/Lab/qc.vqs, S:\Lab\qc.vqs, //server/share/qc.vqs, file:///...) and paths relative to the .md file both work
  • "> [!NOTE]" style callouts (NOTE, TIP, IMPORTANT, WARNING, CAUTION) are shown as boxes
  • raw HTML is not supported and is shown as text, so a page looks the same in any Markdown viewer (and with Qt's own Markdown support, should we switch to it)

Rendering uses md4c (the Markdown parser Qt uses internally) and produces HTML for a QTextBrowser together with styleSheet().

Public Member Functions

string baseDir ()
 Folder of the .md file; relative image and link paths are resolved against it.
int stepIndexForAnchor (string anchor)
string renderStep (int index, bool dark)

Static Public Member Functions

static WorkflowDocument fromFile (string path, string *error=nullptr)
 Reads path. On failure returns an invalid document and fills error.
static WorkflowDocument fromMarkdown (string text, string fallbackTitle=string())
 Parses Markdown text. fallbackTitle is used if there is neither front matter title nor "# Heading".
static string localPath (string href, string baseDir)
static string scriptPath (string href, string baseDir)
static bool isScriptLink (string href)
 True if href is a script link (see scriptPath()), optionally with "?arguments".
static bool opensWithoutAsking (string path)
static Array< string > scriptLinkArguments (string href)
 Arguments of a script link: the part after '?', split at '&' and percent-decoded.
static string slugify (string text)
 GitHub heading anchor: lower case, spaces to '-', punctuation removed.
static string markdownToHtml (string markdown)
 Plain Markdown to HTML conversion (GitHub dialect; raw HTML is escaped and shown as text).
static string styleSheet (bool dark)
 Default style sheet for rendered pages.

Member Function Documentation

◆ localPath()

string localPath ( string href,
string baseDir )
static

Local file a link points to: a path relative to baseDir, an absolute path (drive letter, UNC "//server/share", "/..."), or a file: URL; "?arguments" and "#fragment" are dropped. Empty for other links (https:, mailto:, ...) and for links to a step ("#step"). href is the link target as written or percent-encoded (e.g. from a QUrl).

◆ opensWithoutAsking()

bool opensWithoutAsking ( string path)
static

True if path is a folder or a document type that is opened without asking (PDF, text, Office documents without macros, images, video). Anything else, such as programs, batch files, shortcuts or unknown types, could run something, so the user is asked first.

◆ renderStep()

string renderStep ( int index,
bool dark )

HTML for step index (heading + body), with "Run" links ("vqs:<n>") after vqs blocks and a "▶" marker on links that run a script.

◆ scriptPath()

string scriptPath ( string href,
string baseDir )
static

Local file a script link points to, or an empty string if href is no script link. href is the link target as written or percent-encoded (e.g. from a QUrl); baseDir is the folder relative paths are resolved against. Script links end in .vqs, .qs or .js and are relative paths, absolute paths (drive letter, UNC "//server/share", "/..."), or file: URLs.

◆ stepIndexForAnchor()

int stepIndexForAnchor ( string anchor)

Step for an in-document link target: a step slug, a step title (case-insensitive) or anything that slugifies to a step slug. Returns -1 if there is none.