code: def _format_line(self, side, flag, linenum, text):
          
          try:
              linenum = '%d' % linenum
              id = ' id="%s%s"' % (self._prefix[side], linenum)
          except TypeError:
              # handle blank lines where linenum is '>' or ''
              id = ''
          # replace those things that would get confused with HTML symbols
          text = (
              text.replace("&", "&amp;").replace(">",
                                                 "&gt;").replace("<", "&lt;")
          )
  
          type_ = 'neutral'
          if '\0+' in text:
              type_ = 'add'
          if '\0-' in text:
              if type_ == 'add':
                  type_ = 'chg'
              type_ = 'sub'
          if '\0^' in text:
              type_ = 'chg'
  
          # make space non-breakable so they don't get compressed or line wrapped
          text = text.replace(' ', '&nbsp;').rstrip()
  
          return (
              '<td class="diff_lno"%s>%s</td>'
              '<td class="diff_line diff_line_%s">%s</td>' %
              (id, linenum, type_, text)
          )
docs: Returns HTML markup of "from" / "to" text lines
  
          side -- 0 or 1 indicating "from" or "to" text
          flag -- indicates if difference on line
          linenum -- line number (used for line number column)
          text -- line text to be marked up