Referring to (and inserting) code block links by ID

What I’m trying to do

I am trying to understand how to refer to code blocks by ID. While there is information explaining about putting ^id at the end of a code block, there is much less about how to refer to that using backtick id backtick to “execute” the code blocks in other places. I have been able to make it work (by duplicating the examples on the buttons plugin documentation and making some of my own), I’d like to understand the backtick behavior a little better.

One specific thing I’d like to do: I’d like to see inserted code block executed in edit mode. For example, inline buttons show up fine in edit mode, but the “buttons by reference” (using the backtick thing) only works in read mode (in edit mode, I see the ID in the backticks). Is there something else (besides backticks) that can do this? Or a way to change backtick behavior?

Also: this doesn’t seem to work for tasks code blocks. Is the backtick behavior just for buttons?

Things I have tried

I have been able to make code block references by ID work (mainly learning from the button examples).

I did find the code block id documentation via There's nothing on describing block IDs and references - which lead me to the code block documentation, but told me little about how to “execute” an id once I’ve defined it.

I spent a frustrating morning wondering why the examples didn’t work, until I realized they did work just fine in read mode.

I tried a few experiments using the code block ids with tasks code blocks, but was unable to make them work.

I’d guess it’s specific to Buttons. Code blocks are intended to display code, not execute it. Obsidian and some plugins also use them for execution, but this is the first I’ve heard about doing it in an embed (I don’t use Buttons).

EDIT: I tried it with an embedded search, and that works.

In “”:


In “new”:


The screenshots are from reading view to hide the cursor and extra blank lines, but live preview looks basically the same.

Are you in live preview, and not source mode?

Thank you!

I now understand that the “backtick interpretation of labeled code blocks” is a buttons-specific thing (quite cool to have a plugin do this!)

The behavior I am seeing is in live preview.

I am guessing the problem is that the way that buttons has implemented the backtick referencing doesn’t work in live preview. Which, given that this had to be implemented in a plugin, may not be such an unexpected limitation.

It also explains why I was so unable to find anything in the general documentation.

Update: it looks like this is a known bug in the buttons plugin and it is scheduled to be fixed in an upcoming release!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.