compatibility with xhtml "apos" entity and entity decoding speedup.
This commit is contained in:
+5
-8
@@ -32,6 +32,10 @@ regex_crlf = re.compile('\r|\n')
|
|||||||
|
|
||||||
join = ''.join
|
join = ''.join
|
||||||
|
|
||||||
|
entitydefs = dict(map(lambda (k,v): (k, unichr(v)), name2codepoint.iteritems()))
|
||||||
|
entitydefs.setdefault('apos', u"'")
|
||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'A',
|
'A',
|
||||||
'B',
|
'B',
|
||||||
@@ -2404,7 +2408,7 @@ class web2pyHTMLParser(HTMLParser):
|
|||||||
else:
|
else:
|
||||||
self.parent.append(unichr(int(name)).encode('utf8'))
|
self.parent.append(unichr(int(name)).encode('utf8'))
|
||||||
def handle_entityref(self,name):
|
def handle_entityref(self,name):
|
||||||
self.parent.append(unichr(name2codepoint[name]).encode('utf8'))
|
self.parent.append(entitydefs[name].encode('utf8'))
|
||||||
def handle_endtag(self, tagname):
|
def handle_endtag(self, tagname):
|
||||||
# this deals with unbalanced tags
|
# this deals with unbalanced tags
|
||||||
if tagname==self.last:
|
if tagname==self.last:
|
||||||
@@ -2508,10 +2512,3 @@ class MARKMIN(XmlComponent):
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import doctest
|
import doctest
|
||||||
doctest.testmod()
|
doctest.testmod()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user