How to use placeholders in existing Markdown items?


I suspect the following is a newbie error; in any case, would appreciate some input.

I want the name of Markdown items to be filled in dynamically as the Level 1 Heading of each respective item. So that, if the name changes, the top-level heading is automatically changed to reflect the new name.

The obvious solution appears to be to use placeholders. However, # %recordName% does not lead to the desired result, i.e. it is displayed in preview in the same way (%recordName%).

Am I missing something? And/or is there a way to accomplish this?

You’re probably looking for a script, as there’s no such thing as a placeholder in Markdown per se (to my knowledge)

What specifically are you trying to do?

@BLUEFROG Sorry if it wasn’t clear in the first post.

For my use case, it makes sense to set the name of the markdown item as the top-level headline for the content in that note. So, for all of my Zettelkasten notes I have a macro to quickly add the item name in the first line and add a # symbol in front.

However, item names will likely change every so often over time as things are clarified and reordered. In theory, I would also need to remember to do this for the top-level headline to keep both “in sync”, each time involving some maintenance efforts.

If there was a simple way to automatically insert the item name into the document, this would help to streamline the process.

Are using using H1 headers anywhere else in the document?

Typically I use just a single H1 Header for each document, which reflects the item name.

What you’re apparently wanting to do isn’t accomplished with placeholders. They’re not active and they’d be replaced by other data if they were.

May I ask why you’d be changing the document names often?

Some Markdown editors such as Ulysses don’t show the item name at all when opening documents in tabs. Even when editing in DevonThink, I find that the item name is not prominent enough for my taste, i.e. it’s only shown on the tab.

If there’s no easy solution, I can live with doing the “synchronizing” between item name and top-level header manually.

I do think that a Smart Rule allowing automatic processing of placeholders in existing Markdown documents would offer many worthwhile possibilities. Maybe it’s something for the bucket list… ?

At this time, outside of an Execute Script action, there are no actions that modify the content of a file. Development would have to assess that kind of functionality being provided in actions.

Also again, the placeholders would only be valid once, as they are replaced by the values they refer to, e.g., %shortDate% is replaced by 2021-06-06 in this locale.

1 Like