def _htmlentity_transform(entity):
 if (entity in compat_html_entities.name2codepoint):
  return compat_chr(compat_html_entities.name2codepoint[entity])
 mobj = re.match(u'#(x?[0-9]+)', entity)
 if (mobj is not None):
  numstr = mobj.group(1)
  if numstr.startswith(u'x'):
   base = 16
   numstr = (u'0%s' % numstr)
  else:
   base = 10
  return compat_chr(int(numstr, base))
 return (u'&%s;' % entity)

def _htmlentity_transform ( entity ) : if ( entity in compat_html_entities . name2codepoint ) : return compat_chr ( compat_html_entities . name2codepoint [ entity ] ) mobj = re . match ( u'#(x?[0-9]+)' , entity ) if ( mobj is not None ) : numstr = mobj . group ( 1 ) if numstr . startswith ( u'x' ) : base = 16 numstr = ( u'0%s' % numstr ) else : base = 10 return compat_chr ( int ( numstr , base ) ) return ( u'&%s;' % entity )
transforms an html entity to a character .