def highlight_string(source, unit):
 if (unit is None):
  return []
 highlights = []
 for check in CHECKS:
  if (not CHECKS[check].target):
   continue
  highlights += CHECKS[check].check_highlight(source, unit)
 highlights.sort(key=(lambda x: x[0]))
 for hl_idx in range(0, len(highlights)):
  if (hl_idx >= len(highlights)):
   break
  elref = highlights[hl_idx]
  for hl_idx_next in range((hl_idx + 1), len(highlights)):
   if (hl_idx_next >= len(highlights)):
    break
   eltest = highlights[hl_idx_next]
   if ((eltest[0] >= elref[0]) and (eltest[0] < elref[1])):
    highlights.pop(hl_idx_next)
   elif (eltest[0] > elref[1]):
    break
 return highlights

def highlight_string ( source , unit ) : if ( unit is None ) : return [ ] highlights = [ ] for check in CHECKS : if ( not CHECKS [ check ] . target ) : continue highlights += CHECKS [ check ] . check_highlight ( source , unit ) highlights . sort ( key = ( lambda x : x [ 0 ] ) ) for hl_idx in range ( 0 , len ( highlights ) ) : if ( hl_idx >= len ( highlights ) ) : break elref = highlights [ hl_idx ] for hl_idx_next in range ( ( hl_idx + 1 ) , len ( highlights ) ) : if ( hl_idx_next >= len ( highlights ) ) : break eltest = highlights [ hl_idx_next ] if ( ( eltest [ 0 ] >= elref [ 0 ] ) and ( eltest [ 0 ] < elref [ 1 ] ) ) : highlights . pop ( hl_idx_next ) elif ( eltest [ 0 ] > elref [ 1 ] ) : break return highlights
returns highlights for a string .