code: def save_htmlid(html_id, skiplint=False):
      
      global html_ids
      global lint_errors
  
      # Trailing whitespace
      html_id_clean = html_id.strip()
  
      # Trailing underscores
      html_id_clean = html_id_clean.strip('_')
  
      # Must begin with a letter
      if re.match(r'^[a-zA-Z]', html_id_clean) is None:
          html_id_clean = 'mqc_{}'.format(html_id_clean)
  
      # Replace illegal characters
      html_id_clean = re.sub('[^a-zA-Z0-9_-]+', '_', html_id_clean)
  
      # Validate if linting
      if config.lint and not skiplint:
          modname = ''
          codeline = ''
          callstack = inspect.stack()
          for n in callstack:
              if 'multiqc/modules/' in n[1] and 'base_module.py' not in n[1]:
                  callpath = n[1].split('multiqc/modules/',1)[-1]
                  modname = '>{}< '.format(callpath)
                  codeline = n[4][0].strip()
                  break
      if config.lint and not skiplint and html_id != html_id_clean:
          errmsg = "LINT: {}HTML ID was not clean ('{}' -> '{}') ## {}".format(modname, html_id, html_id_clean, codeline)
          logger.error(errmsg)
          lint_errors.append(errmsg)
  
      # Check for duplicates
      i = 1
      html_id_base = html_id_clean
      while html_id_clean in html_ids:
          html_id_clean = '{}-{}'.format(html_id_base, i)
          i += 1
          if config.lint and not skiplint:
              errmsg = "LINT: {}HTML ID was a duplicate ({}) ## {}".format(modname, html_id_clean, codeline)
              logger.error(errmsg)
              lint_errors.append(errmsg)
  
      # Remember and return
      html_ids.append(html_id_clean)
      return html_id_clean
docs: Take a HTML ID, sanitise for HTML, check for duplicates and save.
      Returns sanitised, unique ID