Intelligently paste Markdown links.
When you paste your clipboard's content into Obsidian, the plugin will check to see if it's a URL. If so, it'll insert the content as a Markdown link, using any selected text as a title. Otherwise, it'll just paste the text as normal.
If you prefer to use a separate command, you can disable the Override paste handler setting, restart Obsidian, and then use the Paste Markdown link command, which can be bound to any key combination of your choice in Obsidian's settings.
This command inserts a link if the clipboard contains a URL and behaves like the standard Insert Markdown link command otherwise, so if you like, you can replace the default Insert Markdown link keybinding with the command provided by this plugin.
If your clipboard contains a URL but you don't want to paste it as a Markdown link, use the Paste URL as plain text command, which is bound by default to Shift + Command + V on macOS / iOS and to Shift + Control + V everywhere else.
The plugin was originally inspired by obsidian-url-into-selection and seeks to improve on it in the following ways:
The ability to fetch page titles was inspired by obsidian-auto-link-title and incorporates the following improvements:
fetch() vs. an Electron window to get HTTP page titles, which is faster and more predictable100% feature parity with these plugins is not a goal, but if you have a feature request or find a bug, please open an issue.
The plugin uses JavaScript's URL constructor to validate URLs. This means the following strings are considered URLs:
https://example.com
http://example.com
file:///path/to/file
But the following are not:
wwww.example.com
example.com
Additionally, URLs containing newlines are not handled, since Obsidian doesn't support multiline links.
If the Fetch page titles on paste setting is enabled, the plugin will attempt to fetch page titles from HTTP URLs and use them as link titles when Override paste handler is enabled. Alternatively, you can also fetch page titles on demand using the Paste link and fetch page title command.
Note that some pages (e.g. SPAs) may not include the full title in their HTML, and behavior may be inconsistent across platforms. Exceptions are handled on a best-case basis, and contributions to add new handlers are very welcome.
You can optionally clean page titles before pasting using regular expressions. Each row in the the plugin's settings has three components, from left to right:
This is how the plugin cleans page titles:
This is not as scary as seems! Let's look at some examples:
GitHub issues: to extract just the issue title from Add dark mode support · Issue #123 · raycast/extensions:
^https?://(?:www\.)?github\.com/.+?/issue^(.+?)\s*·Add dark mode supportYouTube videos: to remove the "- YouTube" suffix from Rust Tutorial Full Course - YouTube:
^https?://(?:www\.)?youtube\.com(.+?)(?:\s*-[^-]*$|$)Rust Tutorial Full CourseGeneral separators: to extract content before common separators such as -, |, •:
.+? (matches any URL)^(.+?)\s*[|–—•·-]How to use promises (from How to use promises - Learn web development | MDN)Stack Overflow template: to reformat titles like javascript - How to format dates? - Stack Overflow to emphasize the technology:
^https?://(?:www\.)?stackoverflow\.com/questions([^-]+) - (.+?) - Stack Overflow[$1] $2[javascript] How to format dates?VS Code URLs: to create titles from VS Code file URLs:
^vscode://file/^vscode://file/.*/(.+?):(\d+) (since this is a non-HTTP URL, this matches against the URL itself)$1 (line $2)script.js (line 42) (from vscode://file/Users/username/project/script.js:42)Additional notes:
Check URL field in the plugin's settings to see if the provided URL produces the expected title.Paste link and fetch full page title command.The paste handler tries to handle these edge cases intelligently:
These edge cases are ignored when using the Paste Markdown link command to better replicate the behavior of the default Insert Markdown link command.
I've found these behaviors useful in my own testing, but if you run into problems with your workflow, please open an issue.