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