Allow [[Internal Links]] inside html tags

Use case or problem

Allow [[Internal Links]] inside html tags.

Links are not interpreted by obsidian.

Proposed solution

Example 1 :

<p>[[Example]]</p>

Example 2 :

<details>
<summary>Click here to view details</summary>
<ul>
<li>[[Internal link 1]]</li>
<li>[[Internal link 2]]</li>
</ul>
</details>

Sorry, this is not possible.

@WhiteNoise

As a workaround, could you explain the kind of URL required so that we could use <a href="..."> links within the HTML?

Markdown’s table support sucks rocks, quite frankly. For certain use cases, we find we have to use HTML tags to get the kinds of tables we need – even for stupid simple stuff, like having the headers in the first column instead of the first row.

If markdown links within HTML tags is impossible to support, how would we format the href value in standard HTML <a> tags to replicate the functionality of bog-standard [[markdown links]]?

From here:

<a href="full-path-to-your-file.md" class="internal-link">Title</a>

I’m using Dataview to parse it for me into the correct format.

Given a string of [[Some file]], here’s the Dataview code to generate a working link:

page = dv.page(dv.parse(THE_STRING))

link = `<a href="${page.file.path}" class="internal-link">${page.file.name}</a>`
3 Likes

Following works for me. (Obsidian Version: 1.0.3)

<a href="my file.md" class="internal-link">my file</a>

Just the full file name (full path not required).

Same technique works for linking the blocks as well.

<a href="my file.md#^block1" class="internal-link">block name</a>

Above is based on original reply from @AlanG .Thanks mate :slight_smile:

3 Likes

Have you tried html <span> tags?

I use the following to right align some text (page links)

<span>
   <p style="text-align: right">
      some text with [[links]] and ~~formatting~~
   </p>
</span>

Which correctly produced right aligned text which I use for backlinks at the bottom of the page.

I doesn’t work in editing mode, but definitely works in reading mode.

some text with [[links]] and formatting

To add some investigation:

You can do this in callouts (introduced after OP?), admonitions, also embedding.

Importantly, filename change propagation works in callouts/embedding and even within the span that the OP shows which breaks the link. It doesn’t work for admonitions unfortunately (I find the code-block like syntax more useful than the callout indentation syntax).

callouts:

>[!note]
><span>[[internal link]]</span>

embedding:

<span>not gonna render here: [[internal link]]</span>
^cats

but it will render here: ![[parent file#^cats]]

Not sure of the OPs use case, but this doesn’t satisfy mine :frowning: