Default PDF link formatting with hotkey: not working (because I don't know how to code) #1637
Unanswered
RankkaApina
asked this question in
Help
Replies: 1 comment 1 reply
-
|
Here are two simpler options, either will work. <%*
let newLink = tp.file.selection().replace(']]', '|PDF]]');
tR += newLink;
-%><% tp.file.selection().replace(']]', '|PDF]]') %>Doing what you originally set out to do is possible but more complicated, as you would need to get access to the active editor instance. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to automate a formatting for a pdf file link, one that I could use with a hotkey, but I'm missing something.
Basically, I'm trying to create a formatting that when I'm done would give me (PDF), where the PDF is the link. I.e. if I have a file link to a pdf, like
[[this-is-my-file.pdf]], when I use my hotkey, it would create the following:([[this-is-my-file.pdf|PDF]]). Preferably this would work so, that when I add the link and my cursor is just after the]], I could hit the hotkey and I would get the formatting. Right now (because I'm still a noob when it comes to js & templater), I would need to select the link, which is fine if I can't make it work exactly as I'd like. However, currently even selecting the link is not working.This is what I got (and I get there maybe multiple things wrong with my approach):
It gives me the following error in console:
Any pointers/ways to fix this?
Beta Was this translation helpful? Give feedback.
All reactions