obsidian-auto-link-title
obsidian-auto-link-title copied to clipboard
[Feature Request] Arbitrary post-processing of title
It would cool if there were a setting which consisted of a JavaScript code-block that would allow us to post-process the title before it's pasted into the document. This is useful for GitHub link titles which are long and have too much information for my taste.
So a setting that would allow me to define a hook like the following:
(url, title) => {
if (/github\.com/.test(url)) {
return title.replace(/^GitHub - ([^:]+):.*/, '$1');
}
return title;
}
If arbitrary code execution is too much, people can do a great deal with regexes only.
+1 - adding a configurable map of URL regex to a templated title would be great for customization
Is there any progress on this? I saw there was a new release.
Also, this pull request seemed related, and was closed without elaboration: https://github.com/zolrath/obsidian-auto-link-title/issues/98.
There are more requests related to this (https://github.com/zolrath/obsidian-auto-link-title/issues/70, https://github.com/zolrath/obsidian-auto-link-title/issues/34, https://github.com/zolrath/obsidian-auto-link-title/issues/80, https://github.com/zolrath/obsidian-auto-link-title/issues/84, https://github.com/zolrath/obsidian-auto-link-title/issues/86). A lot could be solved with simple {{template}} and regex replacements.
Can you provide me with some other examples of how you'd use this feature?
I've got a WIP branch with a GUI asking for a domain, a regex to test against, and the replacement regex:
but would like a few more examples of how you'd intend to use it before I commit to that method.
For example,
- I'd use this for GitHub:
GitHub - [\w\d_]*/(.*)->$1- would make this repo's link title
GitHub - zolrath/obsidian-auto-link-title: Automatically fetch the titles of pasted links->obsidian-auto-link-title: Automatically fetch the titles of pasted links - come to think of it multiple regexes for one domain might come in handy
- this for Wikipedia:
- Wikipedia->| Wikipedia, so this goesBlue jay - Wikipedia->Blue jay | Wikipedia
But that's just off the top of my head. There are also some sites that have a lot of cruft in their titles. Regexes could also be a workaround for #22 to make the resulting titles now less ugly.
Hi! i would really like this feature! Are you still working on it, or can i create a pull request finishing the implementation in the other branch?
Hi! i would really like this feature! Are you still working on it, or can i create a pull request finishing the implementation in the other branch?
Hello! I've been pulled into a work project for the last bit, if you'd like to complete the feature I'd gladly accept a pull request!