Quick Google search link #142
luckman212
started this conversation in
Templates Showcase
Replies: 3 comments 4 replies
-
<%*
if (tp.file.selection() === "" ) {
new Notice('Please select some text first!');
} else {
%>[<% tp.file.selection() %>](https://scholar.google.com/scholar?q=<% encodeURIComponent(tp.file.selection()) %>)<%*
}
%> If you want google scholar search |
Beta Was this translation helpful? Give feedback.
0 replies
-
Why do we escape tp.file.selection() and encodeURIComponent? I think these are available in js without being escaped out from the script. |
Beta Was this translation helpful? Give feedback.
3 replies
-
It's easy to update this script by replacing the notice with an entry. <%*
let searchText = tp.file.selection();
if (searchText === "")
searchText = await tp.system.prompt("Please enter some search text...","",true);
const searchQuery = encodeURIComponent(searchText);
tR = `[${searchText}](https://google.com/search?q=${searchQuery})\n`;
%> |
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
-
Quickly insert a Google Search link as a markdown link.
Beta Was this translation helpful? Give feedback.
All reactions