Access to text of text link?

I’m interested in exporting text links by embedding them in/adjacent to the text from which they are linked. To explain, consider:

A note called “Source Note” whose $Text is “This is some sample text in which the word linked is a text link.”
A text link whose source text in “Source Note” is the word ‘linked’ and whose destination is a note called “Target Note” whose $Text is “Some footnote information.”

Using Action Code or Export Codes can I get access to the source text of a text link, in this case, ‘linked’ and a reference to the note to which it is linked? I’ve done some searching of this forum and ATBRef without turning up something that looked right.

In the ideal case, I’d like to export some Markdown that looked something like this:

This is some sample text in which the word [linked](Some footnote information) is a text link.

My situation is that I have a small number of notes (c. 15) most of which have 1, 2 or 3 text links out to short notes. Each of the linked notes is a sibling of the source note, btw. I would like to build an export template that automates the process of making the linked notes into footnotes of the source document.

I’m open to some post-processing using grep, sed, Pandoc, or something similar. The ultimate destination is Mellel, but for the (semi-)automated export I’d like to wind up with MultiMarkdown or Word or something I can get into Ulysses. (For example, I thought if I could get access to the source texts as strings, I could put these in an attribute, export that attribute, then post-process it to make the right connections/transformations.)

I’d be grateful for information on what is possible in relation to getting the source text of text links in TB or any ideas about how to achieve what I want, please.

Thank you.

In short, no! At present neither action nor export code give programmatic access to text link anchor text.

However, footnotes ring a bell from some years back. IIRC I did a variant of this for Ted Goranson’s (Tinderbox-generated) blog. The trick is to place the footnotes in a non exporting container, whilst letting the footnote notes themselves remain exportable. Then the main note template has extra code to include and foramt the footnote content into the note’s exported page.

Thanks Mark.

1 Like

Does v9 enable export of text link (made using ziplink) into formats such as [some descriptive text](target-of-link)? I did some digging in the XML and I can see how the link is represented (thankfully not buried in RTF like browser links), but as far as I can tell, there is still no way to influence the export format of a text link.

A possible solution is to introduce a property export-textlink-format whose default value is “”. User can specify format string, e.g., [description]($target.name) where $target.name specifies what property of $target to be inserted. In this example, it is the name of the target note, but one could imagine other sorts of target properties (e.g., $target.id).

My understanding from looking at v9 is that more is possible, but still not quite what you want. The new action code for grabbing notes within a certain number of hops, filtered by link type would allow you to export footnotes if your structure is just right. In my case, I have a main note, and then linked notes, within 1 hop, of different link types for different types of footnotes. I’ve not tried it yet, but in my export template for the main note, I will grab all the notes within 1 hop that are of the right link type and append them to the text of the main note. I expect I will be able to do some differentiated formatting too.

So far as I can tell though, there is no way to get the run of text on the main page to which the outbound link is anchored. As a result, there is no way to embed a footnote symbol (or a Markdown formatted link) into the main page text.

Actually, as of v9, I don’t think that is the case as ‘smart URLs’ are now adopted as Tinderbox links, though you may need to de-/re-select the current note for new URL links to show in the Browse Links pop-over.

No, as the ‘ziplink’ method just creates an ordinary text link (and optional return text link). So the question becomes, does Tinderbox expose the anchor text of text links to action or export code. My understanding is no. The Browse Links pop-over does show the anchor text (or part, if long) but otherwise it is only seen as coloured text in $Text.

Delving under the hood, the anchor text is recorded in the <link> tag as a start character offset and character run length within the source note’s plain text (<text>) record.

Whilst you can’t (as described) access anchor text programatically, you can create a link and supply your own anchor text - see ^linkTo()^. Bear in mind the latter has to be written as code by the user (into a template). If you knew, by whatever means, the target note and the desired anchor text you could use a ^action()^ to assemble the ^linkTo()^ on the fly.

Reading back to the start of the thread, this all seems moot if you can’t programmatically get the anchor text of the link. A further issue is addressing the right link. A note can have any of basic links—with no anchor text—or text and web links both of which have anchor text. Were one able, for instance, to call a list of the anchor texts plus their target note’s $Path you could iterate the list and make as set of links.

I think this all rather boils down to a feature request for some way to access text link anchor text via action or export code.

I think this is key (for my purpose). I have been using zip links extensively, but I now realize that I can’t really export them in the way I want (to Markdown) which makes interoperability with other software a bit of a pain. The zip links are kind of stuck in TBX.

I can’t say it often enough, there is no such thing as a ‘zip’ link. There are_text links_ created using the ‘ziplinks’ method. Tinderbox has no addressable notion of a link that is a ‘zip’ link.

I assume underlying this is a misguided notion that links must be like a basic wiki, using an article’s name as the link anchor. But this is a very limited form of linking and leads to all sorts of naming gymnastics; in fact full blown wikis have no such limitations. Tinderbox has no such limitation, though you can use the wiki-like method if you so chose.

I have an approach that should support Markdown export of text links. It may take a little while.