code: def get_html_attrs(kwargs=None):
      
      kwargs = kwargs or {}
      attrs = []
      props = []
  
      classes = kwargs.get('classes', '').strip()
      if classes:
          classes = ' '.join(re.split(r'\s+', classes))
          classes = to_unicode(quoteattr(classes))
          attrs.append('class=%s' % classes)
      try:
          del kwargs['classes']
      except KeyError:
          pass
  
      for key, value in iteritems(kwargs):
          key = key.replace('_', '-')
          key = to_unicode(key)
          if isinstance(value, bool):
              if value is True:
                  props.append(key)
          else:
              value = quoteattr(Markup(value))
              attrs.append(u'%s=%s' % (key, value))
  
      attrs.sort()
      props.sort()
      attrs.extend(props)
      return u' '.join(attrs)
docs: Generate HTML attributes from the provided keyword arguments.
  
      The output value is sorted by the passed keys, to provide consistent
      output.  Because of the frequent use of the normally reserved keyword
      `class`, `classes` is used instead. Also, all underscores are translated
      to regular dashes.
  
      Set any property with a `True` value.
  
      >>> _get_html_attrs({'id': 'text1', 'classes': 'myclass',
          'data_id': 1, 'checked': True})
      u'class="myclass" data-id="1" id="text1" checked'