function lookupEntity(name) {
    // TODO: entity lookup as specified by HTML5 actually depends on the
    // presence of the ";".
    if (ENTITIES.hasOwnProperty(name)) { return ENTITIES[name]; }
    var m = name.match(decimalEscapeRe);
    if (m) {
      return String.fromCharCode(parseInt(m[1], 10));
    } else if (!!(m = name.match(hexEscapeRe))) {
      return String.fromCharCode(parseInt(m[1], 16));
    } else if (entityLookupElement && safeEntityNameRe.test(name)) {
      entityLookupElement.innerHTML = '&' + name + ';';
      var text = entityLookupElement.textContent;
      ENTITIES[name] = text;
      return text;
    } else {
      return '&' + name + ';';
    }
  }
Decodes an HTML entity.

{\@updoc
$ lookupEntity('lt')
# '<'
$ lookupEntity('GT')
# '>'
$ lookupEntity('amp')
# '&'
$ lookupEntity('nbsp')
# '\xA0'
$ lookupEntity('apos')
# "'"
$ lookupEntity('quot')
# '"'
$ lookupEntity('#xa')
# '\n'
$ lookupEntity('#10')
# '\n'
$ lookupEntity('#x0a')
# '\n'
$ lookupEntity('#010')
# '\n'
$ lookupEntity('#x00A')
# '\n'
$ lookupEntity('Pi')      // Known failure
# '\u03A0'
$ lookupEntity('pi')      // Known failure
# '\u03C0'
}

@param {string} name the content between the '&' and the ';'.
@return {string} a single unicode code-point as a string.