How to escape square bracket in link custom display text?

In want to add a link with custom display text that contains square brackets so the link is displayed as [1].

I tried escaping with backslash like so: [[Link Name|\[1\]]], but this incorrectly displays \[1\] where the last backslash is not part of the link text.

How to I correctly escape square brackets within internal links custom text?

You could try some Unicode alternatives. :smile:

[[Link Name|⟬1⟭]]
[[Link Name|⧼1⧽]]
[[Link Name|⦕1⦖]]

Screenshot 2023-09-08 085820

If you find a set you like, you can use GitHub - manic/obsidian-wrap-with-shortcuts: Wrap selected text in custom tags with shortcuts. or Templater and set a hotkey for them.

Do you mean it is not possible to have actual square brackets in link custom text?

I mean… I can just use normal parentheses in that case… but it seems like it should be possible to use square brackets.

I’m not sure. I had never tried using [ ] within the link text before, but tested a few combinations of escaping things, like you, and couldn’t get it. I think it’s related to:

You don’t need to escape the brackets — the link will work.

In my testing on iOS the closing bracket appears in normal text color instead of link color on both Live Preview and Reading View, so Obsidian probably needs some work somewhere, but the link functioned.

Yes, the link works, but the first closing bracket which should have been escaped is parsed as a closing bracket of the link. That is why the last one is considered to be outside the link.

But from @ariehen comment above, I understand that this is in fact a bug. Is my specific use case a known bug or should I fill a bug report?

I think it’s essentially the same bug as the one ariehen linked, but go ahead and post a new bug report (if one doesn’t already exist) because that thread seems focused on Markdown links and this one is about wiki links. If WhiteNoise thinks it belongs with the other report they’ll merge it in.

1 Like

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