If an element node has the only child, and it is of CDATA type, then the extra indentation is omitted (previously this behavior only held for PCDATA children)
git-svn-id: http://pugixml.googlecode.com/svn/trunk@770 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
parent
b979d4c2bd
commit
a18385e1e0
@ -2920,11 +2920,14 @@ namespace
|
|||||||
}
|
}
|
||||||
else if (!node.first_child())
|
else if (!node.first_child())
|
||||||
writer.write(' ', '/', '>', '\n');
|
writer.write(' ', '/', '>', '\n');
|
||||||
else if (node.first_child() == node.last_child() && node.first_child().type() == node_pcdata)
|
else if (node.first_child() == node.last_child() && (node.first_child().type() == node_pcdata || node.first_child().type() == node_cdata))
|
||||||
{
|
{
|
||||||
writer.write('>');
|
writer.write('>');
|
||||||
|
|
||||||
text_output_escaped(writer, node.first_child().value(), ctx_special_pcdata);
|
if (node.first_child().type() == node_pcdata)
|
||||||
|
text_output_escaped(writer, node.first_child().value(), ctx_special_pcdata);
|
||||||
|
else
|
||||||
|
text_output_cdata(writer, node.first_child().value());
|
||||||
|
|
||||||
writer.write('<', '/');
|
writer.write('<', '/');
|
||||||
writer.write(name);
|
writer.write(name);
|
||||||
|
|||||||
@ -45,6 +45,13 @@ TEST_XML(write_cdata_escape, "<![CDATA[value]]>")
|
|||||||
CHECK_NODE(doc, STR("<![CDATA[1]]]]><![CDATA[>2]]]]><![CDATA[>3]]>"));
|
CHECK_NODE(doc, STR("<![CDATA[1]]]]><![CDATA[>2]]]]><![CDATA[>3]]>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_XML(write_cdata_inner, "<node><![CDATA[value]]></node>")
|
||||||
|
{
|
||||||
|
CHECK_NODE(doc, STR("<node><![CDATA[value]]></node>"));
|
||||||
|
CHECK_NODE_EX(doc, STR("<node><![CDATA[value]]></node>\n"), STR(""), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_XML_FLAGS(write_comment, "<!--text-->", parse_default | parse_comments)
|
TEST_XML_FLAGS(write_comment, "<!--text-->", parse_default | parse_comments)
|
||||||
{
|
{
|
||||||
CHECK_NODE(doc, STR("<!--text-->"));
|
CHECK_NODE(doc, STR("<!--text-->"));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user