Simple JavaScript example that should work:
(() => {
const app = Application("DEVONthink 3");
const rec = app.getRecordWithUuid("5A7B65E4-F969-43C2-8B93-EE5D15516F40");
const txt = rec.richText();
const paras = txt.paragraphs();
})()
(The record in question is of type RTF). Instead, it barfs at me that “paragraphs() is not a function”. True, since txt
is simply of type string
. But according to the documentation richText
should deliver a Text object belonging to the (Extended) Text Suite. Which it does, when I use the equivalent AppleScript code:
tell application id "DNtp"
set r to get record with uuid "5A7B65E4-F969-43C2-8B93-EE5D15516F40"
set theText to rich text of r
set paras to paragraphs of theText
set c to count of paras
end tell
Nobody barfs, instead I get the lovely number of 3152 paragraphs.
Question: What would be the correct way to get at the paragraphs of an RTF record in JavaScript?
Since I’m at rich text already: It is a bit confusing that the method get rich text of
seems to return the “rich text” of an HTML record (whatever that might mean - HTML seems to be rich enough already), whereas rich text
(the property) seems to work on other record types as well.