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

Commit5cc0cb6

Browse files
committed
Removed non-ASCII bytes from JSON files, to avoid simplejson portability issues.
Fixed BeautifulSoup treewalker doctype/comment portability issues.--HG--extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%401167
1 parent54181f0 commit5cc0cb6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

‎src/html5lib/treewalkers/soup.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ def getNodeDetails(self, node):
1414
return (_base.DOCUMENT,)
1515

1616
elifisinstance(node,Declaration):# DocumentType
17-
#Slice needed to remove markup added during unicode conversion
18-
m=self.doctype_regexp.match(unicode(node.string)[2:-1])
17+
string=unicode(node.string)
18+
#Slice needed to remove markup added during unicode conversion,
19+
#but only in some versions of BeautifulSoup/Python
20+
ifstring.startswith('<!')andstring.endswith('>'):
21+
string=string[2:-1]
22+
m=self.doctype_regexp.match(string)
1923
#This regexp approach seems wrong and fragile
2024
#but beautiful soup stores the doctype as a single thing and we want the seperate bits
2125
#It should work as long as the tree is created by html5lib itself but may be wrong if it's
@@ -31,7 +35,10 @@ def getNodeDetails(self, node):
3135
return_base.DOCTYPE,name,publicIdor"",systemIdor""
3236

3337
elifisinstance(node,Comment):
34-
return_base.COMMENT,unicode(node.string)[4:-3]
38+
string=unicode(node.string)
39+
ifstring.startswith('<!--')andstring.endswith('-->'):
40+
string=string[4:-3]
41+
return_base.COMMENT,string
3542

3643
elifisinstance(node,unicode):# TextNode
3744
return_base.TEXT,node

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp