You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Select some text from a webpage in Safari, preserving the links it might contain, in markdown format, and send to the clipboard the following:
> [${title}](${url})
>
> ${selectedText}
What I've done
The following code works, except it doesn't preserve links:
let urlAndTitle = await applescript(
String.raw`tell application "Safari" to return {URL, name} of front document`
)
let [url, title] = urlAndTitle.split(/, (.+)/) //split at first comma
let text = await getSelectedText();
let link = `> [${title}](${url})\n> \n> ${text}`
await setSelectedText(link)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi Kiters!
What I'd like to do
Select some text from a webpage in Safari, preserving the links it might contain, in markdown format, and send to the clipboard the following:
What I've done
The following code works, except it doesn't preserve links:
Any idea?
TIA
Beta Was this translation helpful? Give feedback.
All reactions