mirror of https://github.com/python/cpython
merge #4147: minidom's toprettyxml no longer adds whitespace to text nodes.
This commit is contained in:
commit
1d30db459d
|
@ -467,6 +467,13 @@ class MinidomTest(unittest.TestCase):
|
|||
dom.unlink()
|
||||
self.confirm(domstr == str.replace("\n", "\r\n"))
|
||||
|
||||
def test_toPrettyXML_perserves_content_of_text_node(self):
|
||||
str = '<A>B</A>'
|
||||
dom = parseString(str)
|
||||
dom2 = parseString(dom.toprettyxml())
|
||||
self.assertEqual(dom.childNodes[0].childNodes[0].toxml(),
|
||||
dom2.childNodes[0].childNodes[0].toxml())
|
||||
|
||||
def testProcessingInstruction(self):
|
||||
dom = parseString('<e><?mypi \t\n data \t\n ?></e>')
|
||||
pi = dom.documentElement.firstChild
|
||||
|
|
|
@ -836,7 +836,9 @@ class Element(Node):
|
|||
_write_data(writer, attrs[a_name].value)
|
||||
writer.write("\"")
|
||||
if self.childNodes:
|
||||
writer.write(">%s"%(newl))
|
||||
writer.write(">")
|
||||
if self.childNodes[0].nodeType != Node.TEXT_NODE:
|
||||
writer.write(newl)
|
||||
for node in self.childNodes:
|
||||
node.writexml(writer,indent+addindent,addindent,newl)
|
||||
writer.write("%s</%s>%s" % (indent,self.tagName,newl))
|
||||
|
@ -1061,7 +1063,7 @@ class Text(CharacterData):
|
|||
return newText
|
||||
|
||||
def writexml(self, writer, indent="", addindent="", newl=""):
|
||||
_write_data(writer, "%s%s%s"%(indent, self.data, newl))
|
||||
_write_data(writer, self.data)
|
||||
|
||||
# DOM Level 3 (WD 9 April 2002)
|
||||
|
||||
|
|
|
@ -496,6 +496,7 @@ Lou Kates
|
|||
Hiroaki Kawai
|
||||
Sebastien Keim
|
||||
Ryan Kelly
|
||||
Dan Kenigsberg
|
||||
Robert Kern
|
||||
Randall Kern
|
||||
Magnus Kessler
|
||||
|
|
Loading…
Reference in New Issue