Skip to content

Pretty printing for mixed content moves text to a new line and introduces spaces. #163

Open
@frederik

Description

@frederik

Describe the bug

With end({ prettyPrint: true }) mixed inline content is written to a new line, introducing spaces in XML viewers. (e.g. a text will render as "It's bold ." instead of "It's bold.")

To Reproduce
Given the following XML

<sec sec-type="chapter"><title>Introduction</title><p>It's <b>bold</b>.</p></sec>

calling end({ prettyPrint: true }) results in the following output:

<title> Introduction </title>

It's bold .

Expected behavior

I would have expected the p element to keep all inline content

<sec sec-type="chapter">
    <title>Introduction</title>
    <p>It's <b>bold</b>.</p>
</sec>

There is a test for mixed content that tests for the current behavior, I am unsure whether that is correct (Oxygen XML and other editors format the text as expected).

Version:

  • node.js: 16.x
  • xmlbuilder2 3.0.1

Additional context
Highly appreciate this straightforward library! I hope the issue makes sense.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions