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

fix a unicode_literals regression in ihatexml.py#51

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

Closed
ambv wants to merge3 commits intohtml5lib:masterfromambv:ihatexml
Closed
Show file tree
Hide file tree
Changes fromall commits
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
2 changes: 1 addition & 1 deletionhtml5lib/ihatexml.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -260,7 +260,7 @@ def fromXmlName(self, name):
return name

def escapeChar(self, char):
replacement = "U" + hex(ord(char))[2:].upper().rjust(5, "0")
replacement = "U%05X" %ord(char)
self.replaceCache[char] = replacement
return replacement

Expand Down
19 changes: 18 additions & 1 deletionhtml5lib/tests/test_parser2.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
from __future__ import absolute_import, division, unicode_literals

import io
import warnings

from . import support # flake8: noqa
from html5lib import html5parser
from html5lib.constants import namespaces
from html5lib.constants import namespaces, DataLossWarning
from html5lib import treebuilders

import unittest
Expand All@@ -16,6 +17,10 @@ class MoreParserTests(unittest.TestCase):

def setUp(self):
self.dom_tree = treebuilders.getTreeBuilder("dom")
try:
self.lxml_tree = treebuilders.getTreeBuilder("lxml")
except ImportError:
self.lxml_tree = None

def test_assertDoctypeCloneable(self):
parser = html5parser.HTMLParser(tree=self.dom_tree)
Expand All@@ -27,6 +32,18 @@ def test_line_counter(self):
parser = html5parser.HTMLParser(tree=self.dom_tree)
parser.parse("<pre>\nx\n&gt;\n</pre>")

def test_ihatexml(self):
if not self.lxml_tree:
return
parser = html5parser.HTMLParser(tree=self.lxml_tree)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")

parser.parse(b'<p xml:lang="pl">Witam wszystkich')

self.assertEqual(len(w), 1)
self.assertTrue(issubclass(w[-1].category, DataLossWarning))

def test_namespace_html_elements_0_dom(self):
parser = html5parser.HTMLParser(tree=self.dom_tree, namespaceHTMLElements=True)
doc = parser.parse("<html></html>")
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp