]>
Commit | Line | Data |
---|---|---|
1 | """ | |
2 | Internal utility functions. | |
3 | ||
4 | `htmlentitydecode` came from here: | |
5 | http://wiki.python.org/moin/EscapingHtml | |
6 | """ | |
7 | ||
8 | ||
9 | import re | |
10 | from htmlentitydefs import name2codepoint | |
11 | ||
12 | def htmlentitydecode(s): | |
13 | return re.sub( | |
14 | '&(%s);' % '|'.join(name2codepoint), | |
15 | lambda m: unichr(name2codepoint[m.group(1)]), s) | |
16 | ||
17 | __all__ = ["htmlentitydecode"] |