Tinderbox Forum

How to export all links as ‘live’?

I would like to write an export template in which:

  1. all links of a note are included in the exported txt file
  2. these links are all live href links that can be clicked on, leading the file to which they point to open

So far, I have been able to figure out the following:

First: I have placed the following into a rule for the note being exported:

$LinksTo=links.outbound."cross reference|define|agree|disagree|*untitled".$Name;
$LinksFrom=links.inbound."cross reference|define|agree|disagree|*untitled".$Name;

Second: I have made an export template that includes the following code:

# ^value($Name)^
**Links To:** ^value($LinksTo)^^endif ^if($LinksFrom) 
**Links From:** ^value($LinksFrom)^ ^endif 


So far so good: I get a note in which the $Name of the notes linked to this note are included in the exported text.

The step I cannot figure out, if indeed it is possible, is how to get those links to be live. I assume it should be possible, because ZipLinks in a note’s $Text, for example, export correctly in the exported txt file:

# cow 

**Links To:** farms
**Links From:** mammals

definition: a fully grown female animal of a domesticated breed of ox, kept to produce milk or beef: a dairy cow.

Cf. Creatures which have domesticated us: <a href="../Domesticating/cat.md">cat</a>

Can anyone point me in the right direction? Am I trying to do the impossible?

Why not use ^inboundLinks and ^outboundLinks

1 Like

Exactly. No need to invent the wheel.

@talazem see the toolset here.


Most likely because I was ignorant of it. :see_no_evil:

Thank you both!

1 Like

This has worked beautifully, thank you.

Follow-up question, if you’d permit: is there a way to extract values from the inbound or outbound links, and append them to the link created by ^inboundLinks or ^outboundLinks?

So for example

**Links To:** ^outboundLinks(,,", ",)^  

correctly gives me a list of the value of $Name of all linked to notes, as clickable links:

Links To: cats, cow, gnu

I would like append the value of $ID before the value of $Name:

Links To: 12837 cats, 18937 cow, 16349 gnu

I tried to use link designators ‘source’ or ‘destination’, but couldn’t get it to work.

Surely that action gives a semi-colon delimited list. To get a comma+space-delimited list as you then describe, use the link code:

**Links To:** ^outboundLinks(,,", ",)^  

with a result like:

Links To: cats, cow, gnu,

Note you will get a trailing comma+space as the export code places user-supplied pre/post list item strings and doesn’t have a mechanism for not having a first pre-string or last post-string. So, using export template (excerpt):

**Links To:** ^outboundLinks(,"^value($ID)^ ",", ",)^  

I get:

The is no single ^export^ code that returns _all_ (basic/text/web) links—in or outbound— for a note in a single list. 

So what is the and aim of the export here? HTML? Text?  The later choice is pertinent as each offers different opportunities and constraints. Regardless of export format, I'd assume the idea is to create a 'text' zettelkasten so even if exporting via HTML the HTML nature of the documents created is moot compared to plain text?
1 Like

Thanks, Mark.

My mistake was I was blindly copying the code from the TBX Reference page on Source: for your "^value($ID)^ ", I incorrectly had `"^value($ID(source))^".

For my purposes, the above does the trick. For learning purposes:

  • is there any way to have the $ID (or any other information) be part of the live link?
  • instead of displaying the value of $Name, can one replace this in toto for some other value?

As to your question as to the aim: this is for exporting from my Tinderbox zettelkasten file. I am structuring the export templates such that the exported files can (a) be used in other (multi)markdown software like Marked2.app or 1writer, and (b) be printed out onto paper, such that an identifier that serves as an address for the notes gets printed, allowing the reader of the printed notes to know where to go to read linked notes.

My main use of the notes is within Tinderbox, and this more of a belts-and-suspenders approach. (The export in .md files does allow me to access my notes on mobile devices, thus the desire for live links.)

BTW, your quick distinction between basic, text, and web clarified for me the different roles they play, thank you.

Export code goes back a ways and some options are limited. With codes like ^outboundBasicLinks()^ you can’t supply the link’s anchor text. ^linkTo()^ does allow provision of anchor text. However, you’ll need to generate links a different way (via) action code.

Thus my question. Do you need HTML links in the output documents or are they a by-product of the mechanism. You can use ‘HTML’ export to generate text, JSON, XML, whatever. If you want HTML, with working inter-doc links you are more restricted. The reason aTbRef uses hierarchical static pages is because there is no means to export to—for example—a single folder and have inter-page HTML links still work.

I’ve seen (not on-forum) your export templates using Markdown and I’m wondering if it is needed or whether the HTML aspect of things is down to ‘HTML export’ being the most flexible form of export and via its use creating an expectation that the outcome should (only) be HTML (albeit via Markdown).

If the export was making a digital ‘paper’ zettel note, we might make more progress. Still, I ask as I’m just helping and so not the person to judge what final outcome works and what doesn’t.

1 Like

Thank you for the continued help, Mark.

My intention is to export out to Markdown. This means that my links can be preserved if I wish to (or if, one day, I have to) use my note collection in another MD-aware text editor. So the purpose of the HTML is to preserve the links as part of an Markdown file, that is linked to the other Markdown files in the collection. I can thus reap the fruits of my creation of links in Tinderbox even when I am way from my computer, on a mobile device. So the HTML inter-doc links are intentional, and not accidental.

But since I want to be able to print the notes out, and for those paper notes to be linked to the other paper notes, I am using the export template to include unique numbers (like a $ZettelNumber).

I hope I got at what you are asking?

Oops – I just realised that the ^value($ID) is of the note itself, and not of the notes being linked to. Note in the image above all the $ID numbers are the same.

(not tested but) you should be able to use:

**Links To:** ^outboundLinks(,"^value($ID(destination))^ ",", ",)^  

(not tested but) you should be able to use:

**Links To:** ^outboundLinks(,"^value($ID(destination))^ ",", ",)^  

No luck. I’ve read and re-read the pages on source and destination, and can’t get it to work. It just comes back with the $Name of the linked note.

Odd, will check. The above is how I believe these designators work. Clearly more testing needed.