Skip to content

Instantly share code, notes, and snippets.

@th-in-gs
Created May 2, 2023 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save th-in-gs/5de0ecb986f84532c83d0a115b40fbed to your computer and use it in GitHub Desktop.
Save th-in-gs/5de0ecb986f84532c83d0a115b40fbed to your computer and use it in GitHub Desktop.
Subethaedit Markdown Formatting Scripts

Paste these into Script Editor and save them as "Markdown Italicize.scpt" and "Markdown Boldise.scpt" in SubEthaEdit's Script folder (find it by opening it from the Script menu).

on seescriptsettings()
	return {keyboardShortcut:"@i", shortDisplayName:"Markdown Italicize", displayName:"Markdown Italicize"}
end seescriptsettings

tell application "SubEthaEdit"
	begin undo group
	set thetext to the the contents of the selection
	if thetext starts with "_" then
		set the contents of the selection to (characters 2 through ((length of thetext) - 1) of thetext) as string
	else
		set the contents of the selection to the "_" & thetext & "_"
	end if
	end undo group
end tell
on seescriptsettings()
	return {keyboardShortcut:"@b", shortDisplayName:"Markdown Boldize", displayName:"Markdown Boldize"}
end seescriptsettings

tell application "SubEthaEdit"
	begin undo group
	set thetext to the the contents of the selection
	if thetext starts with "__" then
		set the contents of the selection to (characters 3 through ((length of thetext) - 2) of thetext) as string
	else
		set the contents of the selection to the "__" & thetext & "__"
	end if
	end undo group
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment