Add external link to inline code?

I’m trying to take coding notes in obsidian, and want to have pages of separate functions and link them in examples or use cases, but can’t seem to find a way to make the markdown syntax compatible.

For example, say I already have a note on a function called mean() and titled “mean()”, and now I’m taking some other note saying something like “You can call mean() to calculate the average value of an array”, is it possible to link the note to the in-line code block?

I tried putting the [[]] inside and outside the `` but neither works. Adding an alias to the link doesn’t work either.

Are you familiar with block linking? Link to blocks - Obsidian Help

I don’t know if there is a command for it. But if you link to a page, you can type ^ after the link and it will search headers and paragraphs. And you can search for content, including code blocks. And when you find it, it will generate a unique ID and place it after the code block.

As far as I know this will NOT work for sections inside a code block. Just for a single code block as a whole. Obsidian is not aware of any code structure. So it will see a paragraph or a header or a code block as a single entity.

image

And the link will look like this:

[[Your Note Title#^62af81]]

You can also put your own unique code after a block.

[[Your Note Title#^testing]]

image

Thank you for the reply. I am more interest in the formatting. I took a screenshot of a piece of my note (read mode):

image

I am wondering if it’s possible to make the last 3 bullet points into internal links while still displaying the text as code pieces.

I tried something below (in source view) but none of them works.
image

The main purpose of code blocks is to present contained text “as is” without any automatic conversions happening. So when you put a [[link]] between a couple of backticks, everything, including square brackets, gets treated as plain text and doesn’t turn into anything. That’s expected behavior.

Same for putting backticks inside square brackets. Everything between brackets gets treated as a part of a path / filename, hence is taken literally. So any formatting you want to apply to the link has to happen outside of the brackets, which doesn’t work for code blocks for the reason stated above.

I don’t think what you want can be achieved with markdown alone but it should be doable with a Supercharged Links plugin. After all you just want some of your links to look different from the rest.

thank you I’ll check it out!

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