def serialize_tag(tag):
 out = '<'
 if (tag.tag_type == HtmlTagType.CLOSE_TAG):
  out += '/'
 out += tag.tag
 attributes = []
 for (key, val) in tag.attributes.items():
  aout = key
  if (val is not None):
   aout += ('=' + _quotify(val))
  attributes.append(aout)
 if attributes:
  out += (' ' + ' '.join(attributes))
 if (tag.tag_type == HtmlTagType.UNPAIRED_TAG):
  out += '/'
 return (out + '>')

def serialize_tag ( tag ) : out = '<' if ( tag . tag_type == HtmlTagType . CLOSE_TAG ) : out += '/' out += tag . tag attributes = [ ] for ( key , val ) in tag . attributes . items ( ) : aout = key if ( val is not None ) : aout += ( '=' + _quotify ( val ) ) attributes . append ( aout ) if attributes : out += ( ' ' + ' ' . join ( attributes ) ) if ( tag . tag_type == HtmlTagType . UNPAIRED_TAG ) : out += '/' return ( out + '>' )
converts a tag into a string when a slice [tag .