The culprit is the
isn’t
that "’" is not valid ASCII, because of which it doesn't come in the valid range of characters of HTML Markup , thus it escapes it (though it should throw an error)
Hope that solves the issue.
This works for me
from flask import Markup
sentence = '<p> Reading, watching or <span class="matching">listening</span> to the media isn\'t <span class="matching">matching</span><span class="matching">much</span> help either. </p>'
Markup(sentence)
returns
Markup(u'<p> Reading, watching or <span class="matching">listening</span> to the media isn\'t <span class="matching">matching</span><span class="matching">much</span> help either. </p>')
hope that is what is the required output