code: def _convert_flags(self,fromlist,tolist,flaglist,context,numlines):
          
  
          # all anchor names will be generated using the unique "to" prefix
          toprefix = self._prefix[1]
  
          # process change flags, generating middle column of next anchors/links
          next_id = ['']*len(flaglist)
          next_href = ['']*len(flaglist)
          num_chg, in_change = 0, False
          last = 0
          for i,flag in enumerate(flaglist):
              if flag:
                  if not in_change:
                      in_change = True
                      last = i
                      # at the beginning of a change, drop an anchor a few lines
                      # (the context lines) before the change for the previous
                      # link
                      i = max([0,i-numlines])
                      next_id[i] = ' id="difflib_chg_%s_%d"' % (toprefix,num_chg)
                      # at the beginning of a change, drop a link to the next
                      # change
                      num_chg += 1
                      next_href[last] = '<a href="#difflib_chg_%s_%d">n</a>' % (
                           toprefix,num_chg)
              else:
                  in_change = False
          # check for cases where there is no content to avoid exceptions
          if not flaglist:
              flaglist = [False]
              next_id = ['']
              next_href = ['']
              last = 0
              if context:
                  fromlist = ['<td></td><td>&nbsp;No Differences Found&nbsp;</td>']
                  tolist = fromlist
              else:
                  fromlist = tolist = ['<td></td><td>&nbsp;Empty File&nbsp;</td>']
          # if not a change on first line, drop a link
          if not flaglist[0]:
              next_href[0] = '<a href="#difflib_chg_%s_0">f</a>' % toprefix
          # redo the last link to link to the top
          next_href[last] = '<a href="#difflib_chg_%s_top">t</a>' % (toprefix)
  
          return fromlist,tolist,flaglist,next_href,next_id
docs: Makes list of "next" links