Tinderbox Forum

outboundBasicLinks to text file


I’m exporting to text files. I’m trying to list incoming and outgoing links.

If I use this code

[[^outboundBasicLinks ^value($Name)^]]

I’m getting something like this

[[<ul><li><a href="202003081718.html">My second note</a></li></ul> My first note]]

Is it possible to get something like this
[[My Second Note]]

In this case My First Note links to the My Second Note.

or, is this code only for exporting to .html? Is there a way to strip out the html?

I’m reviewing Export Codes, but everything seems like it is focused on exporting to .html.

Since you are formatting the export in what appears to be wiki-links, could you share what you want the exported file to be used for? Ingested by some other application?

Export can be used to produce just about any plain text file, not merely HTML. For example, look at some of the OPML examples folks have posted here.

You can set the $HTMLExportExtension, which defaults to .html to be any other extension. Or you can change it in the HTML Inspector. Tinderbox has roots in HTML export, but that’s just history, not a limitation.

Could you post an example file to help the other readers here understand the context? E.g., is the note “My second note” the note that is being exported, or something else?

FWIW, ^outboundBasicLinks(,,,,)^ should export without the HTML markup.

Yes, export is an old part of the app (Tinderbox dates from c.2001) when blogging was still a thing, and some way before todays unicode-capable RTF. That’s the why.

I see another reply inbound—I’ll read that before continuing, but I do think the above contextual point is useful to bear in mind.

Thanks @PaulWalters and @mwra,

The big goal I’m working toward is to be able to export my tinderbox file to markdown files. I want to have access to them in markdown compatible apps for the iPhone and iPad. I’m reviewing the following threads:

  1. Zettelkasten compatibility with Markdown apps
  2. Zettelkasten export

I got some support on this conversation to get the tags working: How to change commas to semi-colons in List/Set attributes?

When I have the whole system set-up built I will repost to help others.

Each file exported will contain the following:

  1. Title
  2. Date Created
  3. Date Modified
  4. Text of the Note
  5. Citation
  6. Tags
  7. Inbound links
  8. Outbound links
  9. Related notes

I’ve figured out how to add 1-6. I’m trying to figure out 6-8 (bolded above)

I’m trying to work small and incrementally trying to solve one problem at a time so I can better learn to use Tinderbox.

The problem I’m trying to solve is I’m exporting html code and I just want to export plain text.

This is being exported:

[[<ul><li><a href="1583783431.html">1583783431</a></li></ul> 1583783447]]

I want to just export [[1583783431]]

Ideally of the links would export in a list such as

Inbound Links

* [[1583783447]]
* [[1583783600]]

Here is the file. I’ll keep reviewing other examples trying to figure it out.

incoming and outgoing links.tbx (118.7 KB)

OK, here is my solution: incoming and outgoing links2.tbx (117.8 KB)

The result looks like (expand the image to see the links!):

I’ve added 2 new String attributes, $MyInString and $MyOutString. These are added to prototype ‘pNote’ KAs for testing purposes. In actual use they could be removed from the KA.

The main work is done by the ‘pNote’ $Edict:

$MyInString=(links(this).inbound..$ID).nsort.format("","* [[","]]\n","");
$MyOutString=(links(this).outbound..$ID).nsort.format("","* [[","]]\n","");

The building blocks are links(), a numerical sort .nsort (assumes all $Names are numerical values (already set from $ID), then using list.format() to create a string which is saved for use in the template.

I did try doing the above on-the-fly within the template using ^action()^ but it fails because the in/out links to the processed note can’t (I think) be resolved in that context. The .nsort simply ensures the notes list in consistent order (as links() may not always generate the link list in the same order).

This is a bit of a kludge approach as we’re simply doing something hitherto not asked for. IOW, perhaps a more efficient method can be found without each not needing to store (and occasionally re-compute) it’s in/out links. I’ve assumed no aliases are in the loop - but don’t overlook that assumption as you built out your file. I’ve no idea how this file performs at scale - that for someone with the need to test.

1 Like

@mwra, it works beautifully! Thank you so much for you time in putting this together. I never would’ve been able to figure it out without your help.

I am excited and I need to weigh the pros and cons of this approach.


This is an elegant way to capture the incoming and outgoing links of a note. It really speeds up the linking process. I’ve just tested it and it works great in a few different apps for the iPhone and iPad.


  1. All of the files need to be exported to the same folder. This means that if something is in a container or in a different container the links will break.
  2. Aliases don’t work.

Is this something I should write up as a potential feature request or am I way outside of the box?

Tinderbox’s export has always worked off the document outline. I’d ease up for a moment: might it be easier to simply post-process the files exported from Tinderbox, and fix the links that way? As these appear to be plain text, it ought to be possible. Or use AppleScript for export , etc. There are other routes.

Asking for export that changes the source outline to something different, e.g. one single set of files, is something that might require more significant engineering. The ROI might not make sense given the other possibilities at hand. Remember, making a form of zettelkasten is only one of many uses, and over-optimising for one task may affect others, something to bear in mind when making a significant feature request. I’m not suggesting not doing so, but to do mindful of the wider app ecosystem.

1 Like

It’s been a while since I’ve been tinkering with this, but here is the last file I had that I believe achieved a similar outcome to what you’re looking for. Let me know if you have questions about how it works.

zkn_testv5.tbx (137.2 KB)


Interesting! It took a while to figure the process but only in terms of where in the doc it happened. This is, with my file, is a nice example of two different implementations to the same end. Each TBX pre-compiles the [[ ]] delimited lists of in/out links as a user String-type attribute. I used an edict, @derekvan uses agents. Is there a ‘best’ way? I think not. In truth, once you’ve got a method that works, all the magic is behind-the-curtain and you likely won’t need to touch it again. So, it is really a matter of choosing a method you, the file’s user, understand as you will maintain the file over time.

Side note: if I were adopting this file as my own I would add the default /Templates container (by adding a built-in template) and move the templates—currently in /System/Export—into the ‘standard’ templates location. I’d also re-import and re-link the ‘code’ prototype as I think that has also had some changes of late. That’s not critique of this TBX, which is pretty neat, but just as a way of keeping the under-pinnings fettled.

† This standardisation has occurred comparatively recently in Tinderbox’s existence. For long term users, there is no requirement to migrate to such norms. But given the constant evolution of the app, at some point these norms become assumptions for later improvements.

For instance you don’t want your templates becoming, by accident, a composite (composites and $NeverComposite) as quite recent in Tinderbox terms. The ‘HTML’ prototype (it used to be named ‘HTML template’) sets $NeverComposite to true. The built-in Templates folder (if added by the app) sets all new templates (i.e. created in or added to /Templates) to use the ‘HTML’ prototype and thus ensure they don’t composite accidentally.

1 Like