Roam Research’s flavour of Markdown doesn’t handle certain characters well, such as parentheses, so I thought I’d change the Hook > Scripts > Finder > Get Address script to encode them, as below:
set mypath to get URL of item 1 of theItems
set AppleScript's text item delimiters to {"("}
set subject to text items of mypath
set AppleScript's text item delimiters to {"%28"}
set mypath to subject as text
set AppleScript's text item delimiters to {")"}
set subject to text items of mypath
set AppleScript's text item delimiters to {"%29"}
set mypath to subject as text
return mypath
If I inject a display dialog mypath
command, it runs exactly as expected, showing me the file’s URL with the %-escaped parentheses.
But the address that is in the clipboard after Hook has run doesn’t have the escaped versions, it still has the original parentheses.
I’ve successfully changed other scripts to modify the URL returned by Get Address
, so I’m very confused why this one isn’t working. For instance, the same maneuver works perfectly well for Safari links.
Ideas, thoughts, suggestions?