This is definitely a code "smell": if you have to further mutilate the text here to reflect mutilation done inside the text, that is a problem.

Also, are you aware that trailing whitespace is significant syntax in some common extended markdown implementations?