Implement output support for embedded PCDATA values
This is a bit awkward since preserving correct indentation structure requires a bit of extra work, and the closing tag has to be written by _start function to correctly process the rest of the tree.
This commit is contained in:
parent
85d8b225f2
commit
df2a0ad28b
@ -4018,6 +4018,9 @@ PUGI__NS_BEGIN
|
|||||||
if (node->first_attribute)
|
if (node->first_attribute)
|
||||||
node_output_attributes(writer, node, indent, indent_length, flags, depth);
|
node_output_attributes(writer, node, indent, indent_length, flags, depth);
|
||||||
|
|
||||||
|
// element nodes can have value if parse_embed_pcdata was used
|
||||||
|
if (!node->value)
|
||||||
|
{
|
||||||
if (!node->first_child)
|
if (!node->first_child)
|
||||||
{
|
{
|
||||||
writer.write(' ', '/', '>');
|
writer.write(' ', '/', '>');
|
||||||
@ -4031,6 +4034,26 @@ PUGI__NS_BEGIN
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writer.write('>');
|
||||||
|
|
||||||
|
text_output(writer, node->value, ctx_special_pcdata, flags);
|
||||||
|
|
||||||
|
if (!node->first_child)
|
||||||
|
{
|
||||||
|
writer.write('<', '/');
|
||||||
|
writer.write_string(name);
|
||||||
|
writer.write('>');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PUGI__FN void node_output_end(xml_buffered_writer& writer, xml_node_struct* node)
|
PUGI__FN void node_output_end(xml_buffered_writer& writer, xml_node_struct* node)
|
||||||
{
|
{
|
||||||
@ -4136,6 +4159,10 @@ PUGI__NS_BEGIN
|
|||||||
|
|
||||||
if (node_output_start(writer, node, indent, indent_length, flags, depth))
|
if (node_output_start(writer, node, indent, indent_length, flags, depth))
|
||||||
{
|
{
|
||||||
|
// element nodes can have value if parse_embed_pcdata was used
|
||||||
|
if (node->value)
|
||||||
|
indent_flags = 0;
|
||||||
|
|
||||||
node = node->first_child;
|
node = node->first_child;
|
||||||
depth++;
|
depth++;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user