Ability to highlight links without breaking them

This is a continuation of a bug report from == highlight breaks http/https links and spills over to subsequent text

Use case or problem

Type the following into a note:

==http://google.com==

Header receives the highlight by mistake

and, any text
here
as well

unless it’s separated by an empty line

Currently the link opens as google.com==, which often breaks it. There’s currently no easy way to have a URL highlighted.

20250125-001969

Proposed solution

We can have Obsidian detecting ==URL== patterns (with the preceding ==) and prioritizing the “==” as highlight markdown rather than the part of a URL.
Meaning, URL== would be treated as a full URL, while ==URL== would be intelligently parsed as a highlighted URL.

This way:

  1. Link opens correctly, without the == markdown
  2. Subsequent text is displayed without the highlight
  3. Any link that contains “==” would still be functional (since it does not start with == before the protocol indicator)

Current workaround (optional)

Need to add space ==https://google.com ==, but it is an ugly solution & renders the highlight with a trailing space

1 Like

Well, the current solution you can do is to use HTML tag.

<a class="hl-link">https://www.google.com/</a>
.hl-link {
    background-color: rgba(255, 0, 0, 0.2);
    padding: 0.2em 0.25em;
    border-radius: 0.25em;
}

image

That’s neat, haven’t thought of that. It’s still a heavy workaround though

I don’t use Templater plugin but I think it will speed up the highlight process.

  1. Create a link highlight template (.md file) with body.
<a class="hl-link"><% tp.file.selection() %><% tp.file.cursor() %></a>
  1. Configure the hotkey.


  1. Enable “Automatic jump to cursor”.

Now you can use Cmd+Shift+H (or whatever shortcut you config) to encapsulate the link with <a> tag.

1 Like

The problem I have with this approach is that it stays in direct contradiction with one of Obsidian’s principles its been built on, namely that data is yours, is software-agnostic and therefore free to move to any other markdown-based app.
Granted, that’s just some HTML syntax, but it would still break all notes if you move to a markdown-only/no html editor (or require batch processing)

Fundamentally, it’s a rendering issue, not a markup issue. And it’d be great if it could be solved on the presentation layer only

Wrapping the URL in angle brackets appears to work. Would that be workable for you if this isn’t resolved as a feature request? Or does it not work in your local vault?

==<http://google.com>==

_<http://google.com>_

No, you are incorrect. The behavior is actually comply with markdown. Here is the render in VS Code, which is a very versatile markdown editor. It won’t render either.

And many many markdown editors support HTML tag. Check out markdown guide here.

By non-compliant I meant the HTML syntax approach.
The workaround proposed is to mix markdown syntax with HTML syntax (<a> tags). However, that would break in any other editor since it relies on a local css class. Obviously, not the end of the world, but far from elegant for sure.

@gupa neat, wasn’t aware of the angel bracket MD syntax for links. That does indeed solve the highlight spillover issue, the question remaining would be how to implement it so that it’s automatically added under the very same Obsidian highlight shortcut

Okay, your concern on CSS injection is valid. Live with it in Obsidian for so long that I forgot you can’t do it for in apps (but you can for VSCode :)) )