Tinderbox Forum

Publish from Tinderbox to DEVONthink

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^

^text^

^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^

^text^

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

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


^text^

^childLinks^

and HTML text (a HTML instance) containing:

^text^

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.

This sounds a familiar scenario. I should note that if a template is only used to render a note content in a manner that is included in some other note (e.g. parent including only the link counts of each child note as set va the chid’s template) them make sure you’re exporting the containing note, within which use of the desired template will then show (or not).

BTW, selected note export will default to the note’s ‘normal’ location within the whole doc export but only if the doc has been fully exported once (this is how I do quick corrections for typos etc in aTbRef single pages). Otherwise you can export the file anywhere. I note this fact as if your note uses CSS, JS etc and is linked via a relative reference those links may not find their targets if not at the correct relative location.

Still, selected note export is a real boon.

Also, don’t overlook the Preview tab of the text pane.

Thanks for all your (on-target) suggestions, Mark!

I created a new note and poked around in the Attribute Inspector, finding an errant HTMLExportTemplate set to a path not beginning with my non-standard ‘/Document Management/Templates’ path. Changing that has granted me a successful HTML export. I think I’m getting there!

(oddly, I don’t have the strip above the editor with the text/preview/html toggles showing)

1 Like

See the Window menu Show/Hide Text Pane Selector to toggle the Text/Preview/HTML selector buttons on off.

The are hidden by default as if you don’t export, likely you my never need the Preview/HTML tabs.

Once set for a Doc, it remembers the toggle state and uses it for all text pane use (but not in stand-alone text windows)

Hey Adam, I’m guessing that you are using a pretty old version of this tool - one that uses $MyString to hold on to some intermediate data. The most recent version of this file no longer does that - so I think you should have no problem using them together. I will try to update the Marked exporter so it also uses custom attribute names instead of $MyString. But in the mean time, please give it a shot using the latest file, and let me know how it goes.

I just uploaded a newer version that has a “Doctor” helper to check if your document has everything it needs to run, and provides steps on how to set up the document. It should be helpful in upgrading from an older version of this tool, to the newer one. You’d need to delete the old Actions (or it might be named Stamps) container, as well as the Applescripts container. Then you can follow Doctor instructions as shown in the video below:

3 Likes

Hi Pat,

Big fan, I have been using your script since you first posted and shared it. Many, many thanks.

1 question: Is it possible to export to markdown instead of html? If so, would it be possible to explain the steps.

Thanks in advance,
Tom

Thank you for creating such easy to follow tutorial. I’m sure it will help a lot of TB and DT users. When I create the new TB document and follow these instructions, it works fine. However, when I do the same with the existing database, where the view in marked2 is implemented (Preview your Markdown notes using Marked), the links inside the notes stop working in Devonthink.

1 Like