obsidian-minimal icon indicating copy to clipboard operation
obsidian-minimal copied to clipboard

Differentiate between internal and external links

Open nhan000 opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe. It's helpful for me to differentiate between an internal link (knowledge that I actively synthesize) and an external link (information that I haven't yet incorporate into my knowledge base.

Describe the solution you'd like Currently the Links setting in Style Settings only can change link color which govern both Internal and External Links. It'd be great if Internal, External and Unresolved link settings are separated.

nhan000 avatar Jul 13 '22 19:07 nhan000

The reason I haven't done it yet is that it squares the number of scenarios to account for with link color, specifically when it comes to handling links inside of headings, italics, bolded text, unresolved/resolved links, etc. which themselves can have their own colors — you get in a kind of specificity arms race where there is no "right" answer, some people would want the link color to "win", whereas some people would want the formatted text color to "win".

My best recommendation in the near term is to use a snippet because you can configure it exactly as you prefer You can see the current CSS for external vs. internal here: https://github.com/kepano/obsidian-minimal/blob/master/src/scss/features/link-underline.scss

kepano avatar Jul 13 '22 20:07 kepano

Thanks a lot for your reply! What I did for my case is that I use CSS highlight snippets (copied elsewhere, I don't know how to code) to differentiate between different heading levels, which allows the text color of links to be visible even if they're at heading level.

Like this image

If you can support having heading colored highlight instead of colored text that'd be great. Currently I have to tweak quite a bit manually and I'm always nervous that it'll break one day.

nhan000 avatar Jul 13 '22 20:07 nhan000

In case it helps anyone, I had the same issue. I solved it by adding a custom css snippet (custom.css) to the vault, loading it via settings → appearance → CSS snippets and pasting the following code:

body{ --link-unresolved-opacity: 0.7; }

You'll be able to see the changes as soon as you save your file, so if you're using a text editor (e.g. notepad / system equivalent) you can leave Obsidian open as you tweak.

Additional settings from the console:

--link-external-color: --link-external-color-hover: --link-external-decoration: --link-external-decoration-hover: --link-internal-color: --link-internal-color-hover: --link-internal-decoration: --link-unresolved-color: --link-unresolved-opacity: --link-unresolved-decoration-style: --link-unresolved-decoration-color:

There is a good explanation of how to find these settings from the console here.

flatlines avatar Aug 30 '22 10:08 flatlines

As described above this can now be achieved via the new variables in 0.16

kepano avatar Sep 02 '22 04:09 kepano

It seems like the variables changed a bit. This (mostly) works for me:

body{
    /* Color for internal links */
    --link-color: red;
    /* Color for external links */
    --link-external-color: green;
    /* Color for unresolved links */
    --link-unresolved-opacity: 0.7;
    --link-unresolved-color: yellow;
    }

Shown in image:

  1. Unresolved link
  2. Internal link
  3. external link

image

Unresolved links don't work in edit mode though. Not sure whether this is a bug in Obsidian or on purpose:

image

eikowagenknecht avatar Oct 17 '22 07:10 eikowagenknecht

Closed in Minimal 6.1.0

kepano avatar Oct 20 '22 22:10 kepano

@kepano Thank you for giving this setting a UI!

Unresolved links don't work in edit mode though.

This is still the case unfortunately. Any possibility to fix / add this?

eikowagenknecht avatar Oct 21 '22 07:10 eikowagenknecht

@kepano Thank you for giving this setting a UI!

Unresolved links don't work in edit mode though.

This is still the case unfortunately. Any possibility to fix / add this?

Are you talking about source mode or live preview? Should work in Live Preview. Obsidian doesn't have a selector for unresolved links in source mode

kepano avatar Oct 21 '22 18:10 kepano

I was talking about source view. So it seems this is not possible (yet).

eikowagenknecht avatar Oct 22 '22 12:10 eikowagenknecht