'Returns True if the given string *s* contains any mathtext.'

def is_math_text(self, s):

    dollar_count = (s.count(u'$') - s.count(u'\\$'))
    even_dollars = ((dollar_count > 0) and ((dollar_count % 2) == 0))
    if rcParams[u'text.usetex']:
        return (s, u'TeX')
    if even_dollars:
        return (s, True)
    else:
        return (s.replace(u'\\$', u'$'), False)
