def parse(self, text):
tags, results = [], []<EOL>text = self.re_tag.sub(lambda m: self.sub_tag(m, tags, results), text)<EOL>if self.strict and tags:<EOL><INDENT>markup = "<STR_LIT>" % (self.tag_sep[<NUM_LIT:0>], tags.pop(<NUM_LIT:0>), self.tag_sep[<NUM_LIT:1>])<EOL>raise MismatchedTag('<STR_LIT>' % markup)<EOL><DEDENT>if self.always_reset:<EOL><INDENT>if not text.endswith(Style.RESET_ALL):<EOL><INDENT>text += Style.RESET_ALL<EOL><DEDENT><DEDENT>return text<EOL>
Return a string with markup tags converted to ansi-escape sequences.