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

Commit4e8e048

Browse files
committed
Get non-namespaced mode working.
1 parent9041a5d commit4e8e048

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

‎src/html5lib/treebuilders/_base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
importwarnings
21
fromhtml5lib.constantsimportscopingElements,tableInsertModeElements,namespaces
32
try:
43
frozenset
@@ -115,7 +114,6 @@ def __init__(self, namespaceHTMLElements):
115114
self.defaultNamespace="http://www.w3.org/1999/xhtml"
116115
else:
117116
self.defaultNamespace=None
118-
warnings.warn(u"namespaceHTMLElements=False is currently rather broken, you probably don't want to use it")
119117
self.reset()
120118

121119
defreset(self):

‎src/html5lib/treebuilders/etree_lxml.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,7 @@ def insertRoot(self, token):
304304
docStr+=' PUBLIC "%s" "%s"'%(self.doctype.publicIdor"",
305305
self.doctype.systemIdor"")
306306
docStr+=">"
307-
#TODO - this needs to work when elements are not put into the default ns
308-
docStr+="<html xmlns='http://www.w3.org/1999/xhtml'></html>"
307+
docStr+="<THIS_SHOULD_NEVER_APPEAR_PUBLICLY/>"
309308

310309
try:
311310
root=etree.fromstring(docStr)
@@ -321,9 +320,17 @@ def insertRoot(self, token):
321320
self.document=self.documentClass()
322321
self.document._elementTree=root.getroottree()
323322

324-
#Add the root element to the internal child/open data structures
323+
# Give the root element the right name
324+
name=token["name"]
325325
namespace=token.get("namespace",None)
326-
root_element=self.elementClass(token["name"],namespace)
326+
ifnamespaceisNone:
327+
etree_tag=name
328+
else:
329+
etree_tag="{%s}%s"%(namespace,name)
330+
root.tag=etree_tag
331+
332+
#Add the root element to the internal child/open data structures
333+
root_element=self.elementClass(name,namespace)
327334
root_element._element=root
328335
self.document._childNodes.append(root_element)
329336
self.openElements.append(root_element)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp