Change the position of the cursor after a markdown tag is inserted.

If there was selected text, the markdown tag is applied to the selected text and the cursor is then moved at the end of the selected range.
If no text was selected, the tag is inserted and the cursor is set in the middle of the tag so that the user can start typing immediately and see the effect of the markdown tag.