In this case, the note is $ReadOnly (as part of the DEVONthink watch folder process), but a couple of side notes for the later reader wanting to use this which other notes.
eachLink()
, lists all links so potentially, there may be 3 outbound link types (basic, text, web) and 2 inbound link types (basic, text). How then to tell these apart?
In vs Out. Outbound links will have that same $ID as the note whose links are being read (i.e. this
unless using the optional scope argument to read from a different note).
Basic. Has no anchor text.
Text. Has anchor text but no URL.
Web link. Has URL (and anchor text—but the URL is the signifier.
In reverse, checking a single link in the list iterated by eachLink()
and you need to tell all 3 apart:
eachLink(aLink){
if(aLink["url"]!=""){
// this is a web link
}else{
if(aLink["anchor "]!=""){
// this is a text link (has anchor but no url)
}else{
// this is basic link (has neither anchor nor url)
}
}
};
Side note (as discovered testing links today for a separate issue): eachLink()
is currently (v9.5.2) unable to report if a basic or text link has target anchor text (the anchor
value applies to the anchor text at source). This data is also omitted from the Browse Links dialog. Indeed, at present you need to look at the doc’s XML to find which links have target text anchors. There’s no fault here but a slight chick-and-egg problem: to-text links are allowed but not seen much as they are hard to make/check†, so this may be a reason they are not much used.
†. This got harder in the v6+ UI. To make a link to a text selection in the target note, drag a link (basic or text) to the link well on the tab bar. Now select the target note, and then select the desired text within $Text. Leaving the selection in place , drag from the link well onto the selection and release and set the rest of the link settings as normal. You now have a link that points to a target $Text. When the link is followed, Tinderbox will ensure the target text anchor is scrolled into view. So, this might be useful if linking into notes with much $Text, albeit noting that such links are difficult to review (as least in terms of the target anchor text string).