MCPcopy
hub / github.com/csev/py4e / handle_charref

Method handle_charref

code3/bs4/builder/_htmlparser.py:70–86  ·  view source on GitHub ↗
(self, name)

Source from the content-addressed store, hash-verified

68 self.soup.handle_data(data)
69
70 def handle_charref(self, name):
71 # XXX workaround for a bug in HTMLParser. Remove this once
72 # it's fixed in all supported versions.
73 # http://bugs.python.org/issue13633
74 if name.startswith('x'):
75 real_name = int(name.lstrip('x'), 16)
76 elif name.startswith('X'):
77 real_name = int(name.lstrip('X'), 16)
78 else:
79 real_name = int(name)
80
81 try:
82 data = chr(real_name)
83 except (ValueError, OverflowError) as e:
84 data = "\N{REPLACEMENT CHARACTER}"
85
86 self.handle_data(data)
87
88 def handle_entityref(self, name):
89 character = EntitySubstitution.HTML_ENTITY_TO_CHARACTER.get(name)

Callers

nothing calls this directly

Calls 1

handle_dataMethod · 0.95

Tested by

no test coverage detected