Zettelkasten: Questions about Markdown template, scripting

Hello everyone, I’m working on a little markdown template to use DTPO (= Devon Think Pro Office) as a “Zettelkasten” (Look here for what that is and how it has been approached in the past; See this tool for a pretty good modern version of a Zettelkasten, that sadly doesn’t perform all to well).

What I’m trying to accomplish is hopefully not that hard:

  1. I have a very simple Markdown-Template, that looks something like this:
  1. This is what is called a “Zettel”. I put my little “zettel.md” file into the template folder of DTPO and can now easily create a new “Zettel” by clicking on the appropriate Button in the file menu.

  2. This creates a new Zettel that gets called by DTPO “zettel-$number.md” and the sections I defined in the template.

  3. I then go ahead and create the note in the zettel format: A thought that occured to me, a quote etc. I start with giving it a title in the form “Title: Zettel $number: $title”

  4. After I’ve finished writing down, what I wanted to write down, I tag the Zettel with all the appropriate tags I can think of.

  5. When the note is at this stage, what is left to do is the linking. For this I create links back and forth between the penultimate Zettel of a particular tag and this one. For short: I create the ins and outs of my Zettels and note them in the sections of my Zettels.

  6. The links have the form zettel-$number.md. I use this script from forum member korm to create said links. Since I have automatic wikilinking for names and aliases activated in the preferences (DTPO->Preferences->Editing->Wikilinks->Names and Aliases), I can click and navigate my Zettelkasten while editing and viewing (via “Best Alternative”).

  7. This is all great so far. Now, in order to be quicker, I created a little macro in Keyboard Maestro (KM) that helps me with creating what is called a “Folgezettel” (a Zettel the follows the one displayed): I let KM copy the markdown link of the displayed Zettel and let it create a new Zettel. Now I can paste the link that is already in my clipboard to the section “Zettel In”, since it is an incoming Link.

What I want to know how to do now is this:

How to automatically paste that link? Is it possible within a template to do the following: Create a markdown template that uses the info of my cliboard to insert the contents to a particular position in the template? E.g. when I’m having a Link to a preceding Zettel on my clipboard, is there a way to create a template that uses these contents and inserts them under “Zettel In”? Also: It would be nice if the number of the Zettel in the title would be automatically inserted by the template.

How to create a script that works with markdown files, that can find a particular place in a document? It should work something like this: Find the appropriate section of a Zettel and append to the body of that section the clipboard contents.

How to create a script that finds a particular Zettel? I would like to be able to create a link for a Zettel that is not displayed right now. As long as I know the number of the Zettel, I should be fine.

Well, there are a lot of other questions I have as regards to simplifying the work needed to link notes in a two way manner. But any help with the preceding questions would be very much appreciated.

Thank you in advance, I’m looking forward to your ideas and questions (maybe you want to try or have tried in the past to implement a Zettelkasten).

P.S.: I’m not sure if this is the right place for my post. If the admins want to move it someplace else, I’d be fine with it.

Could you define “that link”?

It is possible to use placeholders in a template that will insert certain information in the template. If you browse to DEVONthink > Help > Appendix > Templates > Template Packages you’ll read about how to use placeholders. One of these is %clipboardLink%. You should be able to make a “.dtTemplate” template and in the included “.md” template in that package use the placeholder.

Here’s the problem though: Markdown links are plain text, and they have two parts: “[Link descriptor](link address)” Unless you have a rich text link that you can parse, a plain text link on the clipboard will only have the address portion. You’d still want to modify the “[Link descriptor]” portion.

Here’s an example template using the placeholder:

All you need to do is put this .md file into a folder in ~/Library/Application Support/DEVONthink Pro 2/Templates.noindex and then change the name of the folder to add “.dtTemplate” as an extension. (Finder will ask “are you sure”). Later, put a link on the clipboard – including an “x-devonthink-item://” item link – and then select that template (Data > New from Template > …). You’ll need to manually replace “ZZZZ”, or use a standard link descriptor like “[Reference file here]”.

I suggest not trying to do this with a DEVONthink template, but use KM instead. Lots more flexibility for templating, variables, placeholders, etc.

I always wonder why people want to script “find” or “search” – it’s a really hard task to code and it’s also one that’s been solved already in the software you bought. So, why not just open your file and use “Find”? Or, use “Search” to look at lots of files – the results will be highlighted by DEVONthink.

But, if you want to try this, In a markdown file you’d have to be including a token, or using an anchor. Check with Stackoverflow for various techniques on anchoring. Problem here is that the flavor of Markdown that DEVONthink uses doesn’t reliably recognize anchors.

What does it mean to “create a link for a [document] that is not displayed right now”?

Just a suggestion – have you considered ConnectedText? It’s great for Zettelkasten; does it all and much much more. (Also here, and here.) It’s worth putting a VM onto your Mac or buying a Surface or (ugh) running Boot Camp or (ugh ugh) CrossOver, just to use ConnectedText.

Thank you for your ideas and your help so far, Korm!

Oh, “that link” relates to this:

So with the KM-Macro the problem is not there. Since the clipboard contents looks like this ```

zettel-$number.md

[quote]
I always wonder why people want to script "find" or "search"
[/quote]
Because the problem is about inserting something at a specific place in a note. So when I'd use "Find" or "Search" I might be able to find what I am looking for. Like, say, the section with the heading "# Zettel In". BUT what really needs to happen is: Find me the section, find the paragraph in the section, find the end of that paragraph (the last two are vague, because they vary) and than append a link (as defined before) in a new line after the end of a paragraph. So what's needed is a more or less complex regular expression, I'm guessing. Something like this, maybe: ```

\#\sZettel\sIn\n\n([^\#]*\n)*

``` The last ```

\n

``` in that capture group would then be needed to be replaced with the clipboard contents followed by an ```

\n

``` again.
[quote]
What does it mean to "create a link for a [document] that is not displayed right now"?
[/quote]
Here the ideas was/is to be able to create a link (as defined above) without having to leave my place in DTPO. Say I know that this Zettel should be connected to a Zettel with the number 123, then it should be possible, I thought, to fire up a script that, based on me entering the number 123 into a popup window and pressing return for the script (and devonthink) to put a link like I defined above together. I thought that, maybe, scripts could find out an item link, like the one you get when pressing ctrl-alt-cmd+c in the background. When you're consitent with your naming, I thought, that shouldn't be that hard to puzzle together.


[b]But I get your point. DTPO seems much more like a document storage sollution, or at least a place for pdfs and notes, that don't need to be that heavily interconnected.[/b]
[quote]
Just a suggestion -- have you considered ConnectedText?
[/quote]
(the following is a bit long and rambly, I appologize)

I have to admit, that I am a little bit against doing any of that stuff. This is not on principle and I'm sure that CT is working great for some people. But: As I said in my initial posting: I tried Lüdeckes Zettelkasten, which is [url=http://takingnotenow.blogspot.co.uk/2014/01/luedeckes-zettelkasten-again.html]a suggested alternative[/url] for CT by the person who runs the blog (which I knew and visit form time to time, btw.) you linked to and here's what my experience was:

After two weeks of work I had around 300 Zettel and 123 Keywords. I relied on [url=http://zettelkasten.danielluedecke.de/wiki/doku.php?id=handbuch:registerkarten:folgezettel]the Folgezettel[/url] functionality (you can think of it as a two way linking style) heavily, after all, this is what makes a Zettelkasten. After these 14 days the app got so slow, that I couldn't use it anymore. Since a Zettelkasten is something you'd use for years and years, I'm not sure a virtualised app could a handle that much redundancy/linking complexity, which is crucial for the effects of emergence and serendipity that we all want out of such a thing. Maybe I'm wrong about that. But I'd much rather have either a web application or a native one, that can deal with a lot of linked notes.

Today I used Tinderbox again. And although I like it and the possibilities it provides me, it also seemed not like an application I could trust with 20000 notes (that'd be about three years if i'd keep going like I was…) and the complexity they bring to the table… so to speak. It seemed to me much more like an app you'd use, when you selected some notes from your Zettelkasten and work on a paper, an essay, or even a book. But as a central "notes station"? I don't know…

Before I tried [url=https://plausible.coop/voodoopad/]VoodooPad[/url], [url=https://evernote.com]Evernote[/url], the [url=http://zettelkasten.danielluedecke.de]Zettelkasten App[/url], [url=https://www.zettels.info/en/int/default.asp]zettels.info[/url] the last few days DTPO and today [url=http://www.eastgate.com/Tinderbox/]Tinderbox[/url], I worked for a year, what might become my tool for notes once again: [url=http://ikiwiki.info]ikiwiki[/url]. This a wiki compiler written in perl for the browser with a lot of functionality and a very small footprint. It supports the display of backlinks out of the box, which means, that two way linking is very easily done.

P.S.: I am still open for suggestions to make it work or to look for something somewhere else, but I fear, that I may be in a weird spot, where I know to much, but not enough to know that.  :frowning:

Is there a particular reason your Zettelkasten has to be created with Markdown?

Some of the features you want – e.g., “create a link for a [document] that is not displayed right now” – are more feasible in RTF than Markdown. I’m writing along in an RTF file in DEVONthink and I decide that my thought about “Spring Chickens” would merit a new note. So, I highlight just the words, Spring Chickens, and press ⇧⌘M. When I do that, the term, Spring Chickens, is now a link. But it’s a link to a file that doesn’t yet exist - until I click the link - which automatically creates a new RTF named Spring Chickens. (This feature is configured with options in DEVONthink > Preferences > Edit > WikiLinks)

RTFs can have templates – like any file can – and your template can have all the features mentioned in your postings. There’s no magical connection between Markdown and Zettelkasten.

One can convert RTF to Markdown through scripting, if the need arose. Within DEVONthink, one can convert RTF to plain text (links are lost) or an odd hybrid called a Formatted Note.