Exemplo n.º 1
0
def substitute_numbered_entity(node):
    try:
        value = int(node.leaf())
        # We eliminate some characters such as < and >
        if value in [60, 62]:
            raise Exception()
        node.value = py3compat.unichr(value)
    except:
        node.value = '&#%s;' % value
Exemplo n.º 2
0
 def render_entity(node):
     value = '%s' % node.leaf()
     if value in html_entities:
         node.value = '%s' % py3compat.unichr(html_entities[value])
     else:
         node.value = '&%s;' % value
Exemplo n.º 3
0
def substitute_named_entity(node):
    value = '%s' % node.leaf()
    if value in html_entities and value not in ['lt', 'gt']:
        node.value = py3compat.unichr(html_entities[value])
    else:
        node.value = '&%s;' % value
Exemplo n.º 4
0
 def render_entity(node):
     value = '%s' % node.leaf()
     if value in html_entities:
         node.value = '%s' % py3compat.unichr(html_entities[value])
     else:
         node.value = '&amp;%s;' % value