Skip to content

Commit 9344001

Browse files
committed
fixup! Google Code Issue 157: Add "escape invisible characters" option
1 parent f4f1fb8 commit 9344001

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

html5lib/serializer/htmlserializer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def __init__(self, **kwargs):
167167
def encode(self, string):
168168
assert(isinstance(string, text_type))
169169
if self.escape_invisible:
170-
text = utils.escapeInvisible(text, self.escape_invisible == 'named')
170+
string = utils.escapeInvisible(string, self.escape_invisible == 'named')
171171
if self.encoding:
172172
return string.encode(self.encoding, unicode_encode_errors)
173173
else:

html5lib/utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from types import ModuleType
44

5+
from six import text_type
6+
57
from .constants import invisibleChars
68

79

@@ -87,11 +89,11 @@ def escapeInvisible(text, useNamedEntities=False):
8789
if ord(c) in invisibleChars:
8890
escapable.add(c)
8991
if useNamedEntities:
92+
# for c in escapable:
93+
# name = codepoint2name.get(ord(c))
94+
# escape = "&%s;" % name if name else "&#x%X;" % ord(c)
95+
# text = text.replace(c, escape)
9096
raise NotImplementedError("This doesn't work on Python 3")
91-
for c in escapable:
92-
name = codepoint2name.get(ord(c))
93-
escape = "&%s;" % name if name else "&#x%X;" % ord(c)
94-
text = text.replace(c, escape)
9597
else:
9698
for c in escapable:
9799
text = text.replace(c, "&#x%X;" % ord(c))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy