Publish from Tinderbox to DEVONthink

Oh, my bad. I have misread your comments. Glad to know that you still use it, and support it. It has been very useful to me.

Dear @pat,

First of all: thank you so very much for your Publish to DEVONthink workflow! I find it very useful and use it all the time.

I do have a question about it, though. In some of my TB notes, I have links to Bookends references. Those are turned into regular text into DTPO; is that the desired behavior or have I done something wrong? If the former, would you suggest that I “re-link” those references to BE in DTPO? If the latter, could you please point me in the right direction to correct my mistake? Thank you for your consideration.

Best regards,
Enrico

It’s not desired behavior, but you probably haven’t done something wrong :slight_smile:

Would you be willing to send me a stripped-down version of your TBX? Just leave the one note in that has the bookends link that isn’t working (along with basic infrastructure – e.g. stamps, templates, applescripts). Then I can take a look and see what’s going on.

You can, just be aware that the next time you “publish to DEVONthink” the content will be overwritten. So, you could lock the record in DEVONthink, or duplicate it and make your edits in the duplicated version. At least that way you have something working until we get to the bottom of what’s going on here.

Dear @pat,

Thank you for your kind reply, the helpful clarifications, and the generous offer to look into that.

I have attached here a simplified file with all the infrastructure but only four notes that are linked to one another, and three of which contain links to Bookends references (in blue); hope that is helpful. In any case, please feel free to let me know if there is anything else you need.

Thank you for your consideration.

Best regards,
Enrico

Work - Content - Simplified.tbx (114.3 KB)

Possible fix: instead of copying a bookends link and pasting it directly into Tinderbox note text, you should:

  1. Select the Tinderbox text you want to link
  2. Run Note -> Make Web Link...
  3. Paste the bookends URL into the URL field and press Create Link

I suspect that will do the trick for you.

What follows is my stream-of-consciousness exploration of why your existing links don’t work.


Okay so I took a look at the document you sent (thanks!) and there’s something interesting about it. On my machine, at least, the links don’t render as part of the HTML. If you view the text preview or HTML, you’ll see that the linked text gets converted to plain text.

Another hint is that if you right-click the note and “browse links,” the linked text doesn’t show up in the browse links pane. Typically external links like that will show up as a (web link):

BUT

I do have a hypothesis: maybe Tinderbox doesn’t treat pasted rich text links the same as text links created in Tinderbox. To test this, I selected a DT record and ran “copy item link” to get a rich text link, which I pasted into my Tinderbox note. I got the same result as your doc – it appeared to be a link in the text (and it worked when I clicked on it!) but Tinderbox rendered the link as plain text in its HTML export.

1 Like

Dear @pat,

Thank you very much for your prompt and helpful reply.

You are right: in Tinderbox, the Bookends links in my notes are converted to plain text when viewed in Preview or HTML.

And indeed the procedure you described to create a rich-text link from a DEVONthink record (i.e. “copy item link” and paste it in a Tinderbox note) is exactly what I did to create my links to Bookends references in Tinderbox.

I have tried what you suggested:

And it works: the link appears as link in Preview and HTML, and when “Published to DEVONthink”, it remains a link; however, in both Tinderbox and DEVONthink, the link takes me to the PubMed record in Safari and not to the reference in Bookends. But perhaps I misunderstood what you suggested I do?

Again, thank you very much for your help.

Best regards,
Enrico

hrm I don’t know… when you look in HTML preview, what is the link? Assuming it’s something like bookends://sonnysoftware.com/19087 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://sonnysoftware.com/982”>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://sonnysoftware.com/982.”

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,
Enrico

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,
Enrico

3 Likes

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.


Solution

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?

Thanks!

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!

2 Likes

this is the story of my life :slight_smile:

3 Likes

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.