Publish from Tinderbox to DEVONthink

hrm I don’t know… when you look in HTML preview, what is the link? Assuming it’s something like bookends:// I would expect it to open in Bookends.

If you want to link your Devonthink files with their Bookends entries: now, we have a great user script by Zach: Autolinking Bookends and DEVONthink records - Sonny Software

Pat linked Tinderbox (=notes in html format) with Devonthink
Zach linked Bookends (pdf, epub files) with Devonthink

Devonthink is our hub (center)—works great on the mac as well as the ipad. This is looking great.

Thank you, @pat, for getting back to me on that. Yes, in the HTML pane the link looks something like:

<p><a href=“bookends://”>The dynamics of plant plasma membrane proteins: PINs and beyond</a></p>

And now the link appears as such in the Preview pane too and is preserved in DTPO. But unfortunately, I am now experiencing a different problem: every time I click on the link in the Tinderbox note, I get a message such as:

“There is no application set to open the URL bookends://”

The window in which the message appears allows me to choose an application to open the link, but Bookends is not among the recommended applications to do so; however, if I go through a few steps, I am able to enable Bookends to open the link. Unfortunately, the procedure needs to be repeated every time I click on a link: the system never seems to remember that it should open it with Bookends, even if I had given full access to Bookends in System Preferences > Security & Privacy when I had installed it.

Anyway, I suspect the problem is Bookends, so I requested help through their forum and technical support; I’ll keep you posted.

And thank you, @Desalegn, for reminding me of that great resource: I had come across that post as I was exploring the Bookends forum, but I had completely forgotten about it, so thank you for bringing it back to my attention. I hope to resolve my problem with hypertext links in Bookends soon, so that I can test that script too!

Best regards,

1 Like

Dear all,

I confirm that the problem was Bookends: literally 15 seconds after I had written to Sonny Software’s technical support, they replied that the issue was resolved in a silent update to v13.2. I downloaded v13.2 again and now everything works as expected: I can see the links in the Tex and Preview panes; they are preserved as links after the notes are “Published to DEVONthink”; and if I click on them in either Tinderbox or DTPO, I am taken to the reference in Bookends.

On a related note, it is such a treat to work with software like Tinderbox and Bookends, which comes with such an extraordinary support from the developers: thank you so very much!

Best regards,


Hi @pat, I’m hoping you’d be willing to explain a bit more about how your file builds the x-devonthink links between notes. I’m trying to combine the functionality of your file with my own Zettelkasten file, which exports markdown files in a particular format. Basically, I’m hoping for one TBX file that can export HTML files to DevonThink AND Markdown files to the file system.

I’ve got your Tinderbox file working great. I was even able to add in my own markdown templates and functionality and things were working fine. However, when I export to DevonThink, the link hrefs now point to TBX outline paths instead of x-devonthink links. Can you say more about what parts of the code in the file are creating the x-devonthink links so I can see if I’ve inadvertently changed those? Is $HTMLExportFileName involved?

In case you’re curious to look, I’ve included my file here as well. It looks to me like the $SourceURL is getting set properly (I can click the x-devonthink link in Tinderbox and be taken to the note in DT). It’s just not getting used as the link in the HTML export.

ZKN DevonThink.tbx (162.8 KB)

Thanks much! Your DevonThink export code really is amazing and useful.

1 Like

Solved: See edit below

I’ve tried to debug this a bit but can’t figure it out.

I’ve isolated the relevant code to this bit from the stamp:

linkNotes.each(l) {
  var dtLink($SourceURL(l));
  if(dtLink.beginsWith("x-devonthink-item")) {
    var linkPath($HTMLExportPath(l));
    linkPath = linkPath.substr(1, linkPath.size - 1);
	 theExport = theExport.replace(linkPath, dtLink);
$MyString = theExport;

I try inserting: $Text("/DEBUG") = dtLink and $Text("/DEBUG") = linkPath at various points in both my file and the original file Pat posted. I get the same results in each case, up until theExport, where in Pat’s file the link path is replaced by the x-devonthink link and in my file it’s not. I can’t fathom what the difference is that would cause this issue. Any help greatly appreciated!

One other observation: when theExport is created in the top part of the stamp, in Pat’s file it produces links that look like this:

<p>[[2019061718]] - <a href=\"second_zettel.html\">second zettel</a></p>

In my file it produces:

<p>[[201906171136]] - <a href=\"ZKN/201906171136 - second zettel.html\">second zettel</a></p>

In other words, my file produces text with spaces in the href attribute but Pat’s doesn’t. I had created a rule for changing HTMLExportFileName and that was the culprit here. I removed that rule, blanked out the HTMLExportFileName and am now getting the same results with theExport at the beginning of the script. However, unfortunately, that didn’t solve the problem and the x-devonthink links are not being added.


After creating a new file based on Pat’s template, I went through it step by step until I found the change that made the difference. Basically, when I set the HTMLExportExtension to “.md” it would have the path in the links in DevonThink export. If I set the HTMLExportExtension to “.html” it works again. Dunno what’s going on there, but it seems to be stable. I created a Stamp to set this back and forth depending on what kind of export is desired and it has held so far.

1 Like

This is fantastic. Thank you Pat.

I have two newbie questions, if anyone doesn’t mind helping.

If I already have two notes linked in TB, how do I get that link into the text of the note? I can highlight text and make a link, which will turn that text into a URL. But what if the link is already created (previously created notes with links)? Browse links doesn’t show a URL. Copy Note URL doesn’t give the quiklink URL (or does TB8 not have such a distinction anymore?). I figure it must be stored as an attribute, but I can’t figure out which one. Is it $NoteURL, or the last portion of it that’s a string of numbers?

My second question is about maintaining other links in the note, namely to Bookends. Is this something that should be done in the Apple Script?


If you cmd-option-drag a reference from Bookends to a Tinderbox view, Tinderbox will import the note and try to populate its reference fields from the Bookends reference.

One of the imported attributes is URL, which holds a link to that entry in your Bookends data

Thank you, Mark. I’m actually speaking about the Tinderbox links that are between notes. I know how to make a link by dragging them from note to note, etc. I know that if I highlight text and do that, the text will become a hyperlink. But what if I want to make text a hyperlink as before, but after the link has been created. In otherwards, how do I create the hyperlink in new text to already existant, and linked notes?

As for bookends, the link dissapears when using Pat’s solution.

I’m not quite sure what you mean… sounds like perhaps you’ve created a link directly from one TB note to another? The tool I shared will only export text links – so you’ll have to create a text link from one TB note to another.

You can select text and create a link, in which case your note will have two outgoing links to the same note. One will be a “normal” link and the other will be a text link. Or, you can delete the existing link after creating the text link, so there’s only one.

There’s no way to convert a note-to-note link to a text link, that I know of.

I don’t use bookends, but this post shows a procedure for including bookends links in your notes.

Thanks Pat. I didn’t realize that a text link was different from a note-to-note link. I though text links were somehow referencing the note-to-note link. So of course in this case there’s no magical link to find. I need to make a new one. Got it.

This worked. I read this whole thread, including that post, before I used it but when this didn’t work for me, I didn’t connect the dots. Thanks for pointing me the right way.

It’s working perfectly now and I think you’re amazing for sharing it with the community and then even helping us out with it. I hope I can be forgiven for having grand ideas but being a mere beginner…and mortal.

Have a good one!


this is the story of my life :slight_smile:


I’m really excited about this function, however, I am not having any luck getting it to work for me.

The publish link works with the document I downloaded from here, but when I try to add the function to an existing document I can’t get it to work. I know the problem is my own inexperience with coding as I am stumbling through the instructions. Could someone explain how to install this on an existing document for dummies or who could diagnose my problem? Many thanks!

Hi Pat

I heavily rely on your excellent scripts and find two of them particularly useful: Publish do DEVONthink and view in Marked2 (preview-your-markdown-notes-using-marked). However, I tried to combine them into one database, and it doesn’t work together. When I publish a note to DEVONthink, the attribute “MyString” that creates a temporary file for Marked2 is turn on “!DOCTYPE HTML” and I cannot view the note in Marked2 any more. Could you upload an exemplary TB file that uses both scripts, please? As I work mostly with markdown notes, it would be wonderful to have both of these abilities. Thanks.

Hi Adam, I’m glad you find the tools useful. I’ll take a stab at it this weekend, assuming 2020 doesn’t throw yet another crazy thing in the mean time (knock on wood).

1 Like

Pat, this is great stuff, even if it bristles right up against the rockier edges of Tinderbox when adding this to existing documents.

I’ve been trying to butcher these scripts to export Markdown (or even plain text, which is the same!) to DEVONthink, to not much success - even in terms of getting text out, let alone rewriting internal text links.

I went down the path of least resistance (and possibly least experience) and changed the scripts to create a “markdown” file in DTP, which is working fine - however, I hacked the HTML templates to generate something that looks more like markdown, but the documents always end up empty.

What could I possibly be missing, or getting wrong? I’m blindly assuming a ‘#’ is a legitimate character in a template and doesn’t need escaping. Is there some complex transformation process the scripts perform (and there is what looks like voodoo in there) that I didn’t realise? And how do I take advantage of that DEBUG flag (and what would it do?)

Are these DEVONthink or Tinderbox templates? If the latter, could you post some code. When ouptutting files, pay attention to the extension type as that tells other apps using the file how to handle it. IOW if you send MD code in an ‘.html’ rather then a ‘.md’ file it might confuse the next app in the chain.

In exporting from Tinderbox, do remember that ‘Export’, in the general templated manner is predicated on using HTML unless the user makes changes. Problematic in this is `^text^ exports HTML-processed $Text whereas ^value($Text)^ exports un-HTM-evaluated plain text but also without any inline indication of text links within $Text.

The first step in fixing your issue is to find where/how the process is breaking. I suspect it is unintentional mis-encoding or extensions that are at play rather then something more serious.

Hey Thanks for the response, Mark!

I have placed my templates in ‘/Document Management/Templates’ (rather than a top-level ‘Templates’ path as in Pat’s example).

In there, I have ‘HTML page’ (an instance of the HTML prototype) which has the following text:

Author: Dave Mee
Note: <!--   ** Standard Tinderbox Template [section page] **  -->

# ^title^


^children(/Document Management/Templates/HTML page/HTML item)

Inside that (ie, /Document Management/Templates/HTML page/) is a single note, ‘HTML item’, again with a prototype of HTML, which has the following text:

## ^title^


^children(/Document Management/Templates/HTML page/HTML item)

In /Document Management/Templates/ are two further notes, Links list (a HTML instance) containing:



and HTML text (a HTML instance) containing:


I’ve triple-checked paths are correct everywhere, which I’m very confident of, at least: the system does create a note in DEVONthink, with the correct name, and links bidirectionally between DEVONthink and Tinderbox - but there’s no content in there.

I thought there may be a simple way to butcher the templates to generate plain text instead of Markdown without really telling Tinderbox that’s what it was playing at - but there’s another world of boutique syntax deadlines preclude me from fully exploring!

Whilst it is now recommended to use the ‘standard’ `/Templates’ root container for template notes, if created elsewhere in the doc they show up as available. Still, you can check they actually work by making a small test file specifically to test that possible case.

Though slightly different to action code practice, I generally quote-enclose template paths as well as just template names when a template is provided as an argument, i.e.:

^children("/Document Management/Templates/HTML page/HTML item")^

To where do these templates output (sorry, I’ve not go time to build out a whole workflow here). I assum you are expecting a ‘.md’ file. Are you getting no file? A file with no contents? If you invoke single-file export (File → Export selected note) is the result any different?

Put another way, what output are you expecting, where vs. what/where actually occurs?

I hadn’t considered using the menu item ‘export note’, which does in fact export a note with the correct name, but the contents ‘unable to find this template’ - this feels like the start of a clue!

I’m poking through wrapping paths in quotes and seeing where it takes me. If I can get a proper export working, then I suspect the rest will fall into place, even if that place is directly on my feet.