Ensure that whitespaces are place outside of emphasized elements

Markdown does not allow whitespace characters at the beginning or end of an emphasis (http://spec.commonmark.org/0.12/#emphasis-and-strong-emphasis). This pull requests moves leading and trailing whitespace characters outside of the emphasized elements.

This way all emphasized elements get converted to markdown correctly.