def convert(self, text):
<EOL>self.reset()<EOL>if not isinstance(text, unicode):<EOL><INDENT>text = unicode(text, '<STR_LIT:utf-8>')<EOL><DEDENT>if self.use_file_vars:<EOL><INDENT>emacs_vars = self._get_emacs_vars(text)<EOL>if "<STR_LIT>" in emacs_vars:<EOL><INDENT>splitter = re.compile("<STR_LIT>")<EOL>for e in splitter.split(emacs_vars["<STR_LIT>"]):<EOL><INDENT>if '<STR_LIT:=>' in e:<EOL><INDENT>ename, earg = e.split('<STR_LIT:=>', <NUM_LIT:1>)<EOL>try:<EOL><INDENT>earg = int(earg)<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>ename, earg = e, None<EOL><DEDENT>self.extras[ename] = earg<EOL><DEDENT><DEDENT><DEDENT>text = re.sub("<STR_LIT>", "<STR_LIT:\n>", text)<EOL>text += "<STR_LIT>"<EOL>text = self._detab(text)<EOL>text = self._ws_only_line_re.sub("<STR_LIT>", text)<EOL>if "<STR_LIT>" in self.extras:<EOL><INDENT>text = self._extract_metadata(text)<EOL><DEDENT>text = self.preprocess(text)<EOL>if self.safe_mode:<EOL><INDENT>text = self._hash_html_spans(text)<EOL><DEDENT>text = self._hash_html_blocks(text, raw=True)<EOL>if "<STR_LIT>" in self.extras:<EOL><INDENT>text = self._strip_footnote_definitions(text)<EOL><DEDENT>text = self._strip_link_definitions(text)<EOL>text = self._run_block_gamut(text)<EOL>if "<STR_LIT>" in self.extras:<EOL><INDENT>text = self._add_footnotes(text)<EOL><DEDENT>text = self.postprocess(text)<EOL>text = self._unescape_special_chars(text)<EOL>if self.safe_mode:<EOL><INDENT>text = self._unhash_html_spans(text)<EOL><DEDENT>if "<STR_LIT>" in self.extras:<EOL><INDENT>text = self._a_nofollow.sub(r'<STR_LIT>', text)<EOL><DEDENT>text += "<STR_LIT:\n>"<EOL>rv = UnicodeWithAttrs(text)<EOL>if "<STR_LIT>" in self.extras:<EOL><INDENT>rv._toc = self._toc<EOL><DEDENT>if "<STR_LIT>" in self.extras:<EOL><INDENT>rv.metadata = self.metadata<EOL><DEDENT>return rv<EOL>
Convert the given text.