Pasting links: Prevent repeating the URL

Use case or problem

If I copy some text in a web browser that contains a link where the link label is the same as the URL, the link has some “unnecessary” repetition. For example:

[https://kielikompassi.jyu.fi/opetus/natfrasch/tehtavat/hr_sanaj_relatiivi1.htm](https://kielikompassi.jyu.fi/opetus/natfrasch/tehtavat/hr_sanaj_relatiivi1.htm)

Perhaps it’s because the source web page has defined the link in HTML like this:

<a href="https://kielikompassi.jyu.fi/opetus/natfrasch/tehtavat/hr_sanaj_relatiivi1.htm">
    https://kielikompassi.jyu.fi/opetus/natfrasch/tehtavat/hr_sanaj_relatiivi1.htm
</a>

Proposed solution

When pasting HTML, if a link’s label happens to be the same as the URL, then do not create an element like [](), but instead just write the URL: https://kielikompassi.jyu.fi/opetus/natfrasch/tehtavat/hr_sanaj_relatiivi1.htm.

This is easier to read in the editor mode when the link is not so long anymore. (In preview mode it does not matter, looks the same anyway).

I understand that this is a matter of taste: some might want to always create []() elements. Could this be a toggleable option?

Current workaround (optional)

Currently, I delete the repetitive URL manually.

1 Like

Hi Jare,

I don’t know what OS you’re using, but on Windows and Linux I can use Ctrl-Shift-V (instead of Ctrl-V) and it will paste just the link without the surrounding Markdown decoration.

Maybe this will work for you too.

1 Like

Yea, that’s a good point! I’m using Windows and have used that hotkey in other situations when I have wanted to avoid HTML formatting to be pasted. It’s quite a good workaround, but I can still see a use case for wanting to paste other HTML formatting, but keeping simple URL links as plain text.

For example, I might be copying and pasting a text that contains multiple links with different “styles”.

Some links would be like the one I mentioned before:

[https://kielikompassi.jyu.fi/opetus/natfrasch/tehtavat/hr_sanaj_relatiivi1.htm](https://kielikompassi.jyu.fi/opetus/natfrasch/tehtavat/hr_sanaj_relatiivi1.htm)

But others might be different:

[Swedish exercise](https://kielikompassi.jyu.fi/opetus/natfrasch/tehtavat/hr_sanaj_relatiivi1.htm)

If I copy all of the links at once, and paste into Obsidian by pressing Ctrl + Shift + V, the latter link will become just Swedish exercise with no url at all (= not a link anymore).

But your proposal is a really good solution for many cases, even if some edge cases are uncovered. :slightly_smiling_face:

P.S. My Obsidian version is 0.12.19

3 Likes