Until very recently, copying a URL from my browser (Edge) and pasting it into Obsidian resulted in getting a Markdown formatted link. Now, on both my Macs the link is just posting as a naked URL. I sure would like to get the old functionality back. Any ideas on how to do so?
I don’t think the functionality comes with Obsidian itself. I guess it’s some plugin like Paste URL into Selection or Auto Link Title, isn’t it?
I certainly thought it was native. I don’t remember using a plugin to enable it and in any event, I have not fiddled with plugins recently (other than running updates). I checked Paste URL into Selection and it does not have the functionality I am trying to recapture.
It turns out to have been a feature in Edge that has been changed. Improved copy and paste of URLs in Microsoft Edge - Microsoft Support
I’m using the following Templater snippet with a hotkey combo:
<%*
// By Gareth Stretton
// Source: https://archive.ph/1lMX4
// Get the title from any selected text otherwise ask user for it
let title = tp.file.selection() || await tp.system.prompt("Title?")
if (title) {
// Get the url from clipboard
let url = await tp.system.clipboard()
// if the user was typing add a trailing character
// (i.e. there was no selected text)
let trailingCharacter = tp.file.selection() ? '' : ' '
// Print out (replacing any selected text) with the markdown link
tR += `[${title}](${url})${trailingCharacter}`
} else {
// No title? User quit the prompt... Restore any selected text
tR += tp.file.selection()
}
%>
I credited the creator in the first lines, so one can check his other contributions.
Save the script in the folder that is in the settings of Templater and register a hotkey combination.
It works both ways:
- You have text selected: the selected text will be the
[link text]
(clickable in Live Preview); - You have no text selected: you’ll be prompted to enter something
There was a thread on this forum where another script was duplicating the url in such a way: [https://somewebsite.com](https://somewebsite.com)
but I find this superfluous and the above more elegant, although the latter can have its use cases and it parses a bigger chunk of text for URL’s, while the above script will only work with a clipboard that needs an URL.
Auto Link Title automatically fetches the title of the page and formats the markdown link from copy/pasted URL link. (It also includes ‘paste into selection’ option, for when you already have a text you want to use as title)