code: def parse(self, text):
          
          if self.format == 'markdown':
              try:
                  import markdown
              except ImportError:
                  raise RuntimeError(u"Looks like markdown is not installed")
  
              if text.startswith(u'\ufeff'):  # check for unicode BOM
                  text = text[1:]
  
              return markdown.markdown(text, extensions=self.md_extensions)
          elif self.format == 'restructuredtext':
              try:
                  from landslide.rst import html_body
              except ImportError:
                  raise RuntimeError(u"Looks like docutils are not installed")
  
              html = html_body(text, input_encoding=self.encoding)
  
              # RST generates pretty much markup to be removed in our case
              for (pattern, replacement, mode) in self.RST_REPLACEMENTS:
                  html = re.sub(re.compile(pattern, mode), replacement, html, 0)
  
              return html.strip()
          elif self.format == 'textile':
              try:
                  import textile
              except ImportError:
                  raise RuntimeError(u"Looks like textile is not installed")
  
              text = text.replace('\n---\n', '\n<hr />\n')
  
              return textile.textile(text, encoding=self.encoding)
          else:
              raise NotImplementedError(u"Unsupported format %s, cannot parse"
                                        % self.format)
docs: Parses and renders a text as HTML regarding current format.