Custom Apple Services for DevonThink 3

Hi there,

I am trying to create an Apple Service that is fairly similar to the “out of the box” services that come with DevonThink.

When right clicking a text selection, DevonThink allows to save the snippet as a note. I suppose this works just by creating a text file with the text selection as its content in the inbox folder of the DevonThink database.

Is it possible to expand on this functionality such that the snippet is embedded within a markdown template with a quote signifier (>) in front of it?
Using a template would allow me to apply a css style-sheet to all my quotes, which I had to, until now, inert myself for every new note.

Is there also the possibility to read metadata from the document the snippet is taken from, such as author and title and include them with a header indicator (#) in the template.

I hope some of you can point me in the right direction.

Thanks in advance for your help!

It’s (still) possible to create services using Automator and a small script (e.g. AppleScript or shell script) could process the input and then create a new item in DEVONthink 3 via an AppleScript action. However, the future of Automator is currently unclear.

Note the author and title aren’t necessarily present in documents. What would be the expected output in those situations?

In this case those fields could stay blank.

Do you know whether it is possible to apply a markdown template (with embedded css) to the “selection”?

No, you can’t apply a template to a selection. Templates are not things to be applied. They are recurrently used items that are imported.

You could easily create stock verbiage and create Markdown documents with it. Here’s a simple example…

property markdownBoilerplate : "<link rel=\"stylesheet\" href=\"styles/styles.css\">

_This is some information you want to always include in the **Markdown file**._

tell application id "DNtp"
	create record with {name:"New Markdown", content:markdownBoilerplate, type:markdown} in current group
end tell