def convert(latex): math = Element('math') math.pretty = True row = math.append_child('mrow') _classify_subgroup(aggregate(latex), row) return str(math)