docs: def clean(text):
      """
      Transforms wiki markup.
      @see https://www.mediawiki.org/wiki/Help:Formatting
      """
  
  
  
      text = bold_italic.sub(r'\1', text)
      text = bold.sub(r'\1', text)
      text = italic_quote.sub(r'"\1"', text)
      text = italic.sub(r'"\1"', text)
      text = quote_quote.sub(r'"\1"', text)
      # residuals of unbalanced quotes
      text = text.replace("'''", '').replace("''", '"')
      text = newlines.sub(r'\n', text)
      text = bulletlist.sub(r'', text)
  
      # Collect spans
  
      spans = []
      # Drop HTML comments
      for m in comment.finditer(text):
              spans.append((m.start(), m.end()))
  
      # Drop self-closing tags
      for pattern in selfClosing_tag_patterns:
          for m in pattern.finditer(text):
              spans.append((m.start(), m.end()))
  
      # Drop ignored tags
      for left, right in ignored_tag_patterns:
          for m in left.finditer(text):
              spans.append((m.start(), m.end()))
          for m in right.finditer(text):
              spans.append((m.start(), m.end()))
  
      # Bulk remove all spans
      text = dropSpans(spans, text)
  
      # Drop discarded elements
      for tag in discardElements:
          text = dropNested(text, r'<\s*%s\b[^>/]*>' % tag, r'<\s*/\s*%s>' % tag)
  
      # Expand placeholders
      for pattern, placeholder in placeholder_tag_patterns:
          index = 1
          for match in pattern.finditer(text):
              text = text.replace(match.group(), '%s_%d' % (placeholder, index))
              index += 1
  
      text = text.replace('<<', u'Â«').replace('>>', u'Â»')
  
      #############################################
  
      # Cleanup text
      text = text.replace('\t', ' ')
      text = spaces.sub(' ', text)
      text = dots.sub('...', text)
      text = re.sub(u' (,:\.\)\]Â»)', r'\1', text)
      text = re.sub(u'(\[\(Â«) ', r'\1', text)
      text = re.sub(r'\n\W+?\n', '\n', text, flags=re.U) # lines with only punctuations
      text = text.replace(',,', ',').replace(',.', '.')
  
      return text