Skip to content

Processing instructions disrupt formatting #762

@adamalston

Description

@adamalston

Hi, I've encountered an issue with the plugin where processing instructions within XML files disrupt formatting.

Input (test.xml)

<list><value id="all"><label>All</label></value><value id="one-one"><?group one?><label>One</label></value><value id="one-two"><?group one?><label>Two</label></value><value id="two-one"><?group two?><label>One</label></value><value id="two-two"><?group two?><label>Two</label></value></list>

Command:

npx prettier --plugin=@prettier/plugin-xml --tab-width 4 --xml-whitespace-sensitivity "ignore" --print-width 180 test.xml

Output:

<list>
    <value id="all">
        <label>All</label>
    </value>
    <value id="one-one">
        <?group one?><label>One</label></value><value id="one-two"><?group one?><label>Two</label></value><value id="two-one"><?group two?><label>One</label></value><value id="two-two"><?group two?>
        <label>Two</label>
    </value>
</list>

Expected output:

<list>
    <value id="all">
        <label>All</label>
    </value>
    <value id="one-one">
        <?group one?>
        <label>One</label>
    </value>
    <value id="one-two">
        <?group one?>
        <label>Two</label>
    </value>
    <value id="two-one">
        <?group two?>
        <label>One</label>
    </value>
    <value id="two-two">
        <?group two?>
        <label>Two</label>
    </value>
</list>

Any suggestions or fixes would be appreciated. Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions