Scripting: HTMLContent of (visible) document?

For scripted operations like:

  • Copy as MD (or some other format),
  • export visible lines to .docx etc

It might be useful, at some point, to have scripted access to the HTML for the whole document, and particularly for the visible (focused, unfolded) subdocument.

(the existing row.htmlContent is excellent for inline formatting, but doesn’t include the nesting of rows)

We can already get:

  • document HTML through the file system, and
  • HTML for the visible part of document via the clipboard (select all, copy, pasteboard item)

but in due course, if it looked feasible, direct script property access to document (and document section) HTML would allow for less screen flicker during a script run : )

Can you already do this with export (to get HTML), process, and then import (to set HTML)?

Ah … that looks promising, and I think I missed it :slight_smile:

Many thanks.

Probably means it’s not well tested … let me know what you find!

1 Like

Perfect – exactly what I needed:

(() => {
    "use strict";

    const doc = Application("Bike");

    return doc.exists() ? (
            from: doc.rows.where({visible: true}),
            as: "bike format",
            all: false
    ) : "No documents open in Bike";
1 Like