Formatting Curio link names

Hooking Curio documents, whether using the built in linking or the deeplink script (see Using hook with Curio) create a verbose header that starts everything with Curio project .
Here’s a short script that can make things easier to parse:

tell application "Curio"
	set theLink to (markdown link to selected item of active document) as string
end tell
set theLink to findAndReplaceInText(theLink, "Curio project \"", "")
set theLink to findAndReplaceInText(theLink, "\" > \"", " > ")
set theLink to findAndReplaceInText(theLink, "\"]", "]")
return theLink

on findAndReplaceInText(theText, theSearchString, theReplacementString)
	set AppleScript's text item delimiters to theSearchString
	set theTextItems to every text item of theText
	set AppleScript's text item delimiters to theReplacementString
	set theText to theTextItems as string
	set AppleScript's text item delimiters to ""
	return theText
end findAndReplaceInText

This is not fancy or mysterious: it’s the original deeplink script with the Apple recommended method to replacing text in strings.

@georgezengobi came through with some Curio advanced prefs that make the AppleScript nightmare go away. Existing prefs are :

defaults write com.zengobi.curio "Hyperlink Organizer Item Title Format" -string "Curio project \"%@\" > \"%@\""
defaults write com.zengobi.curio "Hyperlink Figure Title Format" -string "Curio project \"%@\" > \"%@\""

Replacing everything after -string makes it do what I want. I have set it up as:

defaults write com.zengobi.curio "Hyperlink Organizer Item Title Format" -string " %@ > %@"
defaults write com.zengobi.curio "Hyperlink Figure Title Format" -string " %@ > %@"
3 Likes

Thank you very much for digging into this and sharing it, @seishonagon . We have added a section to Using Hook with Curio – Hook page on the issue; it contains a link to this forum topic.

1 Like