Inserting URL-type links into markdown notes

I’m confused. I have a markdown note in DT3 for Mac, and I’m in source view, but the link icon is grayed out and I don’t see a way of making selected text a hyperlink to a URL.

Am I missing something?

The formatting bar is used for different record types, in case of Markdown records making a link is not supported.

There’s no built-in way to turn selected text into a hyperlink.

To turn a URL into a hyperlink add < and > to it:

<https://discourse.devontechnologies.com/>

If you want a custom title then use this:

[Link title](https://discourse.devontechnologies.com/)

Of course, that begs the question: why not?

Because it‘s Markdown? In Markdown you write the formatting along with the flow of text. Selecting text and applying formatting afterwards is not how Markdown works. A developer can of course implement a way to handle selected text but that begs the question: What do you want to happen?

Edit: I see now what you mean. I completely overlooked the fact that DEVONthink meanwhile supports formatting of selected Markdown text in e.g. bold. FWIW here’s a script that creates a hyperlink

-- Create Markdown hyperlink with selected text

tell application id "DNtp"
	try
		if not (exists think window 1) then error "Please select some Markdown text"
		set theRecord to content record of think window 1
		if theRecord = missing value then error "Please select some Markdown text"
		set theType to (type of theRecord) as string
		if theType is not in {"markdown", "«constant ****mkdn»"} then error "Please select some Markdown text"
		set theSelectedText to selected text of think window 1 as string
		if theSelectedText = "" then error "Please select some Markdown text"
		activate
		set theURL to (display name editor default answer "" info "URL:")
		if theURL does not contain "://" then set theURL to "http://" & theURL
		set selected text of think window 1 to "[" & theSelectedText & "](" & theURL & ")"
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		return
	end try
end tell