docs: def build_config(config, filename=None):
      """\
      Builds a configuration and returns it. The config contains only keywords,
      which are supported by the serializer. Unsupported values are ignored.
      """
      # Done here since it seems not to be possible to detect if an argument
      # was supplied by the user or if it's the default argument.
      # If using type=lambda v: None if v in ('transparent', 'trans') else v
      # we cannot detect if "None" comes from "transparent" or the default value
      for clr in ('color', 'background'):
          val = config.pop(clr, None)
          if val in ('transparent', 'trans'):
              config[clr] = None
          elif val:
              config[clr] = val
      # SVG
      for name in ('svgid', 'svgclass', 'lineclass'):
          if config.get(name, None) is None:
              config.pop(name, None)
      if config.pop('no_classes', False):
          config['svgclass'] = None
          config['lineclass'] = None
      if filename is not None:
          ext = filename[filename.rfind('.') + 1:].lower()
          if ext == 'svgz':  # There is no svgz serializer, use same config as svg
              ext = 'svg'
          supported_args = _EXT_TO_KW_MAPPING.get(ext, ())
          # Drop unsupported arguments from config rather than getting a
          # "unsupported keyword" exception
          for k in list(config):
              if k not in supported_args:
                  del config[k]
      return config