GNOME Bugzilla – Bug 644986
Indent fails after comment with xmlTextWriter
Last modified: 2021-07-05 13:21:43 UTC
If you use xmlTextWriter with indentation enabled, after writing a comment followed by a closing tag, the closing tag is not indented. If something else follows the comment then the closing tag is correctly indented. Here is an example to demonstrate the problem. #include <libxml/xmlwriter.h> int main(void) { xmlTextWriterPtr output = xmlNewTextWriterFilename("test.xml", 0); xmlTextWriterStartDocument(output, NULL, "UTF-8", NULL); xmlTextWriterSetIndent(output, 1); xmlTextWriterSetIndentString(output, BAD_CAST "\t"); xmlTextWriterStartElement(output, BAD_CAST "root"); xmlTextWriterStartElement(output, BAD_CAST "first"); xmlTextWriterStartElement(output, BAD_CAST "second"); xmlTextWriterWriteComment(output, BAD_CAST "closing tag below this will not be indented"); // Uncomment this and the indenting works correctly //xmlTextWriterWriteElement(output, BAD_CAST "dummy", BAD_CAST "dummy"); xmlTextWriterEndElement(output); xmlTextWriterEndElement(output); xmlTextWriterEndElement(output); xmlTextWriterEndDocument(output); return 0; } Output with 2.7.7 and 2.7.8: <?xml version="1.0" encoding="UTF-8"?> <root> <first> <second> <!--closing tag below this will not be indented--> </second> </first> </root>
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxml2/-/issues/ Thank you for your understanding and your help.