vschroeter / obsidian-virtual-linker

Plugin for obsidian that automatically generates virtual links for text within your notes that match with the titles or aliases of other notes in your vault.
Other
135 stars 5 forks source link

[Feature Request] Ignore formatting when matching #59

Open Salamander230 opened 2 months ago

Salamander230 commented 2 months ago

I was wondering if it can be possible to match aliases/filenames while ignoring formatting (like bold, italic, underline, highlight, strikethrough, etc.)

For example, in the phrase **DNA** ==**replication**== enzymes are required for <u>DNA replication</u>, the recognized phrases would be DNA replication enzymes and DNA replication if they are aliases/filenames in the vault.

Thanks again for your work on this wonderful plugin :)

vschroeter commented 1 month ago

While implementing a solution to this problem, I ran into the following problem: How should the formatting of such a match be handled? I cannot add additional formatting within a contiguous virtual link that is already formatted as a link element.

Is it okay if the formatting disappears? Or should it be displayed in source code style?

Salamander230 commented 1 month ago

I think keeping the formatting would be best.

Perhaps the solution to this can be to split up the whole link for a match into individual links within each piece of contiguously formatted text (this way the formatting encases individual link parts instead of being inside one big virtual link).

The whole match can then be wrapped in one span element that can be targeted by css to behave as if it's one whole link on hovering or clicking (even though the span element technically isn't a link, but all it's individual parts are).

For example, in the source code: <span><a><b>This</b> is a link</a></span> would become: <span><b><a>This</a></b><a> is a link</a></span>

Also, using the example I gave earlier: **DNA** ==**replication**== enzymes are required for <u>DNA replication</u> would be formatted as the following, given the recognized phrases DNA replication enzymes and DNA replication:

<span><b><a>DNA</a></b><a> </a><mark><b><a>replication</a></b></mark><a> enzymes</a></span> are required for <span><u><a>DNA replication</a></u></span>

vschroeter commented 1 month ago

Sounds good 👍🏻 But it will be some time before I find the time to implement it

Salamander230 commented 1 month ago

No worries. Thank you for your work :)