Convert escaped html characters into unescaped html characters.
    For example: "&lt;b&gt;" becomes "<b>".
768073
def unescape_html(statement):
    
    import html

    statement.text = html.unescape(statement.text)

    return statement
467147
def css_unescape(content, string=False):
    

    def replace(m):
        """Replace with the appropriate substitute."""

        if m.group(1):
            codepoint = int(m.group(1)[1:], 16)
            if codepoint == 0:
                codepoint = UNICODE_REPLACEMENT_CHAR
            value = util.uchr(codepoint)
        elif m.group(2):
            value = m.group(2)[1:]
        elif m.group(3):
            value = '\ufffd'
        else:
            value = ''

        return value

    return (RE_CSS_ESC if not string else RE_CSS_STR_ESC).sub(replace, content)
1063364
def _html_escape(string):
    """"""

    html_codes = {
        '"': '&quot;',
        '<': '&lt;',
        '>': '&gt;',
    }

    # & must be handled first
    string = string.replace('&', '&amp;')
    for char in html_codes:
        string = string.replace(char, html_codes[char])
    return string
745072
public static String unescapeVerbatim(String content)
    {
        StringBuffer unescapedContent = new StringBuffer();

        boolean escaped = false;
        char[] buff = content.toCharArray();
        for (int i = 0; i < buff.length; ++i) {
            if (!escaped) {
                if (buff[i] == '~') {
                    escaped = true;
                    continue;
                }
            } else {
                if (i < (i = matchVerbatimSyntax(buff, i, '{'))) {
                    unescapedContent.append("{{{");
                    escaped = false;
                    continue;
                } else if (i < (i = matchVerbatimSyntax(buff, i, '}'))) {
                    unescapedContent.append("}}}");
                    escaped = false;
                    continue;
                } else {
                    unescapedContent.append('~');
                }

                escaped = false;
            }

            unescapedContent.append(buff[i]);
        }

        return unescapedContent.toString();
    }
236251
public static String escapeHtml(String htmlString) {
		StringBuffer sb = new StringBuffer(htmlString.length());
		// true if last char was blank
		boolean lastWasBlankChar = false;
		int len = htmlString.length();
		char c;

		for (int i = 0; i < len; i++)
		{
			c = htmlString.charAt(i);
			if (c == ' ') {
				// blank gets extra work,
				// this solves the problem you get if you replace all
				// blanks with &nbsp;, if you do that you loss
				// word breaking
				if (lastWasBlankChar) {
					lastWasBlankChar = false;
					sb.append("&nbsp;");
				}
				else {
					lastWasBlankChar = true;
					sb.append(' ');
				}
			}
			else {
				lastWasBlankChar = false;
				//
				// HTML Special Chars
				if (c == '"')
					sb.append("&quot;");
				else if (c == '&')
					sb.append("&amp;");
				else if (c == '<')
					sb.append("&lt;");
				else if (c == '>')
					sb.append("&gt;");
				else if (c == '/')
					sb.append("-");
				else if (c == '\\')
					sb.append("-");
				else if (c == '\n')
					// Handle Newline
					sb.append("&lt;br/&gt;");
				else {
					int ci = 0xffff & c;
					if (ci < 160 )
						// nothing special only 7 Bit
						sb.append(c);
					else {
						// Not 7 Bit use the unicode system
						sb.append("&#");
						sb.append(String.valueOf(ci));
						sb.append(';');
					}
				}
			}
		}
		return sb.toString();
	}
892346
def remove_escapes(self):
        
        chars = []

        i = 0
        while i < len(self.string):
            char = self.string[i]
            if char == "\\":
                i += 1
            else:
                chars.append(char)

            i += 1

        return "".join(chars)
671090
def escape(self, string):
        
        html_entities = {"&": "&amp;", '<': '&lt;', '>': '&gt;'}
        return HTML("".join(html_entities.get(c, c) for c in string))
920071
def _unescape_fixup(match):
    
    text = match.group(0)
    if text[:2] == "&#":
        # character reference
        try:
            if text[:3] == "&#x":
                codept = int(text[3:-1], 16)
            else:
                codept = int(text[2:-1])
            if 0x80 <= codept < 0xa0:
                # Decode this range of characters as Windows-1252, as Web
                # browsers do in practice.
                return bytes([codept]).decode('sloppy-windows-1252')
            else:
                return chr(codept)
        except ValueError:
            return text
    else:
        # This is a named entity; if it's a known HTML5 entity, replace
        # it with the appropriate character.
        try:
            return entities.html5[text[1:]]
        except KeyError:
            return text
601893
function unescape (line) {
  var retv = _.replace(line, propEscapeRE, '$1');
  retv = _.replace(line, unicodeEscapeRE, function (m) {
    return String.fromCharCode(parseInt(m, 16));
  });
  if (retv !== line) {
    debug('removed escapes from: %s => %s', line, retv);
  }
  return retv;
}
137836
def _escape_markdown_literals(string):
    
    literals = list("\\`*_{}[]()<>#+-.!:|")
    escape = lambda c: '\\' + c if c in literals else c
    return "".join(map(escape, string))
1341161
def _clean_html(html):
    
    content = html.replace(u'&#x000A;', u'\n').replace(u'¶', '')
    content = _LINK_PATTERN.sub(u'', content)
    content = _HTML_TAG_PATTERN.sub(u'', content)
    content = _BACKSLASH_PATTERN.sub(u'\n', content)
    return content
1029052
def xhtml_unescape(value: Union[str, bytes]) -> str:
    """"""
    return re.sub(r"&(#?)(\w+?);", _convert_entity, _unicode(value))
736285
def unescape( text ):
    """"""
    
    if isinstance( text, basestring ):
        if '&amp;' in text:
            text = text.replace( '&amp;', '&' )
        if '&gt;' in text:
            text = text.replace( '&gt;', '>' )
        if '&lt;' in text:
            text = text.replace( '&lt;', '<' )
        if '&quot;' in text:
            text = text.replace( '&quot;', '\"' )

    return text
1055519
function escapeJsonQuotes(json) {
      return JSON.stringify(json)
        .replace(/'/g, "&amp;apos;")
        .replace(/"/g, "&amp;quot;")
        /**
         * Codepen was unescaping &lt; (<) and &gt; (>) which caused, on some demos,
         * an unclosed elements (like <md-select>).
         * Used different unicode lookalike characters so it won't be considered as an element
         */
        .replace(/&amp;lt;/g, "&#x02C2;") // http://graphemica.com/%CB%82
        .replace(/&amp;gt;/g, "&#x02C3;"); // http://graphemica.com/%CB%83
    }
850059
function (rawHtml) {
            var matchKeys = Object.keys(options.unescape);
            if (matchKeys.length === 0) {
                return rawHtml;
            }
            var pattern = new RegExp('(' + matchKeys.join('|') + ')', 'g');
            return rawHtml.replace(pattern, function (match) {
                return options.unescape[match];
            });
        }
1344216
function unescape(str) {

    return str.replace(constants.REGEX.unescape, (match, hex1, hex2, hex3, octal, special) => {

        let hex = hex1 !== undefined ? hex1 : hex2 !== undefined ? hex2 : hex3 !== undefined ? hex3 : undefined;

        if (hex !== undefined) {
            return String.fromCodePoint(parseInt(hex, 16));

        } else if (octal !== undefined) {
            return String.fromCodePoint(parseInt(octal, 8));

        } else {
            return constants.SPECIAL_CHARS[special];
        }

    });

}
926017
def convert(html):
	""""""
	bs = BeautifulSoup(html, 'html.parser')
	_markdownify(bs)
	ret = unicode(bs).replace(u'\xa0', '&nbsp;')
	ret = re.sub(r'\n{3,}', r'\n\n', ret)
	# ! FIXME: hack
	ret = re.sub(r'&lt;&lt;&lt;FLOATING LINK: (.+)&gt;&gt;&gt;', r'<\1>', ret)
	# ! FIXME: hack
	sp = re.split(r'(&lt;&lt;&lt;BLOCKQUOTE: .*?&gt;&gt;&gt;)', ret, flags=re.DOTALL)
	for i,e in enumerate(sp):
		if e[:len('&lt;&lt;&lt;BLOCKQUOTE:')] == '&lt;&lt;&lt;BLOCKQUOTE:':
			sp[i] = '> ' + e[len('&lt;&lt;&lt;BLOCKQUOTE:') : -len('&gt;&gt;&gt;')]
			sp[i] = sp[i].replace('\n', '\n> ')
	ret = ''.join(sp)
	return ret.strip('\n')