Skip to content

Bug in writing XML with indents #276

Open
@lwilli

Description

@lwilli

First, let me say thank you for providing this library!

I was working on a function to prettify XML using this library and I ran into some interesting behavior (bug?) when using a Writer with indentation.

In the Readme, there is this example XML (truncated):

<tag1 att1 = "test">
    <tag2><!--Test comment-->Test</tag2>
</tag1>

When I remove the new lines and indentation spaces from this, and then read and re-write this using a Writer like Writer::new_with_indent(Vec::new(), b' ', 2), I get this:

<tag1 att1 = "test">
    <tag2>
    <!--Test comment-->Test</tag2>
</tag1>

The strange thing here is that the tag2 tags do not line up. This appears to be due to how Writer::write_event() handles not breaking new lines for text fields, but doesn't consider whether any other events have been written after the opening tag and before the Text.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions