docs: def build_highlight_objects(html, highlights, uniformize_html=True):
      '''converts a dict of pretty_name --> [tuple(string, score), ...] to
      `Highlight` objects as specified above.
  
      '''
      if uniformize_html:
          try:
              html = uniform_html(html.encode('utf-8')).decode('utf-8')
          except Exception, exc:
              logger.info('failed to get uniform_html(%d bytes) --> %s',
                          len(html), exc, exc_info=True)
              html = None
  
      highlight_objects = []
      for category, phrase_scores in highlights.iteritems():
          for (phrase, score) in phrase_scores:
              hl = dict(
                  score=score,
                  category=category,
                  )
              ranges = make_xpath_ranges(html, phrase)
              if ranges:
                  hl['xranges'] = [{'range': r} for r in ranges]
              elif phrase in html:
                  hl['strings'] = [phrase]
              else:
                  hl['regexes'] = [{
                      'regex': phrase,
                      'flags': 'i',
                  }]
              highlight_objects.append(hl)
      return highlight_objects