Ah, I think now I got you.
My approach is toggling, every Markdown markup (like italics) has its own shortcut which switches it on and off. This is my muscle memory’s preferred way to write because I use rich text apps too and that’s how they work. And since I don’t mind if I write in italics or if the text gets italicized only after the closing askterisk I can use the simple script from above that just inserts single or double asterisk instead of inserting 2/4 and placing the cursor in between.
You on the other hand want a pair of Markdown markups, the cursor in between, and a single “escape” keyboard shortcut for all Markdown markups, right?
The question is, which ones? A single asterisk (or underscore), double asterisks, and triple asterisks (for bold-italic)? More? Like brackets (which can be Markdown) too?
An action could check if any characters/glyphs right to the cursor do exist, and if so, check a list containing at least three, two or one asterisks, and if any of the character/glyph sequences are detected right to the cursor move the cursor to the right of the detected sequence.
If you decided to not only go for asterisks but brackets too—should the “escape” action only move to the right of one detected character/glyph sequence or all of them? For example:
[^1 … ( … **Bold text in brackets in a footnote.|**)]
|
is the cursor position. Where should the action move it? Right behind the double asterisks: **|
? Or right behind the squared bracket: **)]|
?
Which ever way, it can be done. But I don’t know how to set that (or any) action to the Return
key just with Drafts. Additional tools like Keyboard Maestro or Better Touch Tool could provide it though.
But that would make the action more complicated because it would have to identify for every single Return
if it is simply meant as Return
or as “escape”.