Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Google Code Issue 157: Add "escape invisible characters" option#38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
gsnedders wants to merge2 commits intomaster
base:master
Choose a base branch
Loading
fromgcode-157
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
fixup! Google Code Issue 157: Add "escape invisible characters" option
  • Loading branch information
@gsnedders
gsnedders committedMay 4, 2013
commit93440015e6e41f1bab0162ce27f323b65f4cd6e8
2 changes: 1 addition & 1 deletionhtml5lib/serializer/htmlserializer.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -167,7 +167,7 @@ def __init__(self, **kwargs):
def encode(self, string):
assert(isinstance(string, text_type))
if self.escape_invisible:
text = utils.escapeInvisible(text, self.escape_invisible == 'named')
string = utils.escapeInvisible(string, self.escape_invisible == 'named')
if self.encoding:
return string.encode(self.encoding, unicode_encode_errors)
else:
Expand Down
10 changes: 6 additions & 4 deletionshtml5lib/utils.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,8 @@

from types import ModuleType

from six import text_type

from .constants import invisibleChars


Expand DownExpand Up@@ -87,11 +89,11 @@ def escapeInvisible(text, useNamedEntities=False):
if ord(c) in invisibleChars:
escapable.add(c)
if useNamedEntities:
# for c in escapable:
# name = codepoint2name.get(ord(c))
# escape = "&%s;" % name if name else "&#x%X;" % ord(c)
# text = text.replace(c, escape)
raise NotImplementedError("This doesn't work on Python 3")
for c in escapable:
name = codepoint2name.get(ord(c))
escape = "&%s;" % name if name else "&#x%X;" % ord(c)
text = text.replace(c, escape)
else:
for c in escapable:
text = text.replace(c, "&#x%X;" % ord(c))
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp