diff options
-rw-r--r-- | NEWS.txt | 4 | ||||
-rw-r--r-- | bs4/__init__.py | 2 | ||||
-rw-r--r-- | bs4/builder/_lxml.py | 2 | ||||
-rw-r--r-- | bs4/testing.py | 6 |
4 files changed, 8 insertions, 6 deletions
@@ -1,8 +1,10 @@ -= 4.0.0b9 () = += 4.0.0b9 (20110228) = * Fixed the string representation of DOCTYPEs that have both a public ID and a system ID. +* Fixed the generated XML declaration. + * Renamed Tag.nsprefix to Tag.prefix, for consistency with NamespacedAttribute. diff --git a/bs4/__init__.py b/bs4/__init__.py index cbd0fd6..7a36493 100644 --- a/bs4/__init__.py +++ b/bs4/__init__.py @@ -319,7 +319,7 @@ class BeautifulSoup(Tag): encoding_part = '' if eventual_encoding != None: encoding_part = ' encoding="%s"' % eventual_encoding - prefix = u'<?xml version="1.0"%s>\n' % encoding_part + prefix = u'<?xml version="1.0"%s?>\n' % encoding_part else: prefix = u'' if not pretty_print: diff --git a/bs4/builder/_lxml.py b/bs4/builder/_lxml.py index e5e30d4..39ad396 100644 --- a/bs4/builder/_lxml.py +++ b/bs4/builder/_lxml.py @@ -142,7 +142,7 @@ class LXMLTreeBuilderForXML(TreeBuilder): def test_fragment_to_document(self, fragment): """See `TreeBuilder`.""" - return u'<?xml version="1.0" encoding="utf-8">\n%s' % fragment + return u'<?xml version="1.0" encoding="utf-8"?>\n%s' % fragment class LXMLTreeBuilder(HTMLTreeBuilder, LXMLTreeBuilderForXML): diff --git a/bs4/testing.py b/bs4/testing.py index 49644c3..717e721 100644 --- a/bs4/testing.py +++ b/bs4/testing.py @@ -370,17 +370,17 @@ class XMLTreeBuilderSmokeTest(object): def test_docstring_generated(self): soup = self.soup("<root/>") self.assertEqual( - soup.encode(), b'<?xml version="1.0" encoding="utf-8">\n<root/>') + soup.encode(), b'<?xml version="1.0" encoding="utf-8"?>\n<root/>') def test_docstring_includes_correct_encoding(self): soup = self.soup("<root/>") self.assertEqual( soup.encode("latin1"), - b'<?xml version="1.0" encoding="latin1">\n<root/>') + b'<?xml version="1.0" encoding="latin1"?>\n<root/>') def test_real_xhtml_document(self): """A real XHTML document should come out the same as it went in.""" - markup = b"""<?xml version="1.0" encoding="utf-8"> + markup = b"""<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title>Hello.</title></head> |