Replace selection with link to URL?

I am trying to get the selected text from DEVONthink, then create a URL based on the text and then update the selection with the new link.

So, in my document I may have

Please see [John 3:16] for more information.

[John 3:16] being the selected text. I can get the text, I can create the URL string (gnpcb.org/esv/search/?q=John+3%3A16), but I cannot figure out how to then replace the selected text in DEVONthink with a link to the new URL, with the original text content. So, in the end, it will read the same,

Please see John 3:16 for more information.

But John 3:16 will now be a link to gnpcb.org/esv/search/?q=John+3%3A16

Any help would be appriciated!

Jeremt

1 Like

Hi, Jeremy: Sometimes when you turn a problem upside down, it gets easier to solve. :slight_smile:

First, paste into the text your clickable hyperlink.

Now select the link string and edit it to “John 3:16”.

Now you have what you wanted. The text string is a clickable hyperlink.

I missed a critical part of my message. I want to do this via AppleScript. Reason being is I deal with a lot of text and scripture references. So, it’s easy for me to type in my document Jo 3:16; 3:20-22; Ma 5:18 … instead of going to esv, entering the text, the copying the link, going back to devon think, doing all the link stuff, etc…

So, I want to have:

John 3:16 is about God’s love.

Then, I want to highlight John 3:16 w/mouse, click the script menu, convert to esv link and be done with it. Via apple script, I already get the selected text, I am also already creating the URL in a string (escaping values, putting on the right search query, etc…) … The only thing I am not able to figure out how to do is with apple script to then convert the selected text into a hyperlink.

So, for a simple example, how would I say convert the selected text to a link to google.com via AppleScript?

Jeremy

Jeremy,

here’s a basic script to do this:


tell application "DEVONthink Pro"
	tell selected text of think window 1
		set URL to "http://www.google.com"
	end tell
end tell

1 Like

Wow. That was much easier than I thought. I was making it too difficult, thanks!