Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve text content formatting in experimental formatter #1331

Closed
JessicaJHee opened this issue Oct 13, 2022 · 0 comments · Fixed by #1336
Closed

Improve text content formatting in experimental formatter #1331

JessicaJHee opened this issue Oct 13, 2022 · 0 comments · Fixed by #1336
Assignees
Labels
formatting This issue or enhancement is related to formatting support
Milestone

Comments

@JessicaJHee
Copy link
Contributor

JessicaJHee commented Oct 13, 2022

Currently the experimental formatter will normalize the space before and after the entire text content by default. Here is the current behavior:
Before formatting:

<a>
  Content
  <b>
    Content2
    Content3
  </b>
</a>

After formatting:

<a> Content <b> Content2
    Content3
  </b>
</a>

For reference, in IJ, if there is an line break in the text, the text will be indented. If there is no line break, it will remove the spaces between the text and element tag.
Before formatting:

<a>         Content       test
    <b>
        Content2
                   Content3
    </b>
</a>

After formatting:

<a>Content test
    <b>
        Content2
        Content3
    </b>
</a>

There is an option in IJ to keep line breaks in text (true by default), when this is set to false, the content lines are joined. (note that it will not snap the text content to the same line as the 'b' tag if there is a line break present)
After formatting with keep line breaks in text set to false:

<a>Content
    <b>
        Content2 Content3
    </b>
</a>

Referencing the way it works IJ, my suggestions are to:

  1. mimic how the text content formatting is done by default in the same way as IJ where it will respect any existing line breaks and indent the text if needed. It will also normalize the spaces between text in the same line.
  2. keep the joinContentLines setting but change it so that it will keep the new line between the element tag and text if there exists one.
@JessicaJHee JessicaJHee changed the title Have xml.format.joinContentLines to true as default behavior in experimental formatter Improve text content formatting in experimental formatter Oct 13, 2022
@JessicaJHee JessicaJHee added the formatting This issue or enhancement is related to formatting support label Oct 13, 2022
@JessicaJHee JessicaJHee self-assigned this Oct 17, 2022
@angelozerr angelozerr added this to the 0.23.0 milestone Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatting This issue or enhancement is related to formatting support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants