AppleScript interface to link of attribute run?

Not a real obstacle, because we can do this kind of thing directly with the XML of each row, but as far as I can see, the .link property of each attribute run in the .textContent of a row:

  • always returns a non-empty HTML string (whether or not there is in fact a link in that attribute run)
  • but the string returned always has "undefined" as the href value (rather than a URL string) even for runs which do have an attribute attached to them.

Test script (in JS):

Expand disclosure triangle to view JS source
(() => {
    "use strict";

    const doc = Application("Bike");

    return doc.exists() ? (
            _not: [{name: ""}]
            row => row.textContent.attributeRuns()
            .map(run =>
    ) : "No document open in Bike.";

macOS 13.3.1 Bike 1.11.1

1 Like

Iā€™m not sure where the difference is, but this seems to work:

tell front document of application "Bike"
	tell selection row
		set runLinks to {}
		repeat with eachRun in attribute runs of text content
			set end of runLinks to link of eachRun
		end repeat
		return runLinks
	end tell
end tell

And actually this works too:

const doc = Application("Bike")
const selectionRow = doc.selectionRow

I guess something about evaluation of attributeRuns() into a value loses context. I think they are converted to strings. And String does have a built in link function that means something completely different then the link attribute.

1 Like

Perfect. Thanks !

1 Like