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

Comments in xml flexforms are indented wrong #246

Open
wtfred opened this issue Nov 25, 2024 · 2 comments
Open

Comments in xml flexforms are indented wrong #246

wtfred opened this issue Nov 25, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@wtfred
Copy link

wtfred commented Nov 25, 2024

When you have comments in xml flexforms, your indentation is getting broken

If you have this

<?xml version="1.0"?>
<T3DataStructure>
    <sheets>
        <sDEF>
            <ROOT>
                <sheetTitle>Sheet Title</sheetTitle>
                <type>array</type>
                <el>
                    <!-- test comment -->
                    <selectSingleColumn>
                        <config>
                            <type>select</type>
                            <renderType>selectSingle</renderType>
                            <items type="array">
                                <numIndex index="0" type="array">
                                    <label/>
                                    <value/>
                                </numIndex>
                                <numIndex index="1" type="array">
                                    <label>Label 1</label>
                                    <value>1</value>
                                </numIndex>
                                <numIndex index="2" type="array">
                                    <label>Label 2</label>
                                    <value>2</value>
                                </numIndex>
                                <numIndex index="3" type="array">
                                    <label>Label 3</label>
                                    <value>3</value>
                                </numIndex>
                            </items>
                        </config>
                    </selectSingleColumn>
                </el>
            </ROOT>
        </sDEF>
    </sheets>
</T3DataStructure>

Fractor will indent it like this

<?xml version="1.0"?>
<T3DataStructure>
    <sheets>
        <sDEF>
            <ROOT>
                <sheetTitle>Sheet Title</sheetTitle>
                <type>array</type>
                <el>
                    <!-- test comment -->
                        <selectSingleColumn>
                            <config>
                                <type>select</type>
                                <renderType>selectSingle</renderType>
                                <items type="array">
                                    <numIndex index="0" type="array">
                                        <label/>
                                        <value/>
                                    </numIndex>
                                    <numIndex index="1" type="array">
                                        <label>Label 1</label>
                                        <value>1</value>
                                    </numIndex>
                                    <numIndex index="2" type="array">
                                        <label>Label 2</label>
                                        <value>2</value>
                                    </numIndex>
                                    <numIndex index="3" type="array">
                                        <label>Label 3</label>
                                        <value>3</value>
                                    </numIndex>
                                </items>
                            </config>
                        </selectSingleColumn>
                    </el>
                </ROOT>
            </sDEF>
        </sheets>
    </T3DataStructure>

The more comments you have, the more it get shifted to the right

<?xml version="1.0"?>
<T3DataStructure>
    <sheets>
        <sDEF>
            <ROOT>
                <sheetTitle>Sheet Title</sheetTitle>
                <type>array</type>
                <el>
                    <!-- test comment -->
                        <selectSingleColumn>
                            <config>
                                <type>select</type>
                                <renderType>selectSingle</renderType>
                                <items type="array">
                                    <numIndex index="0" type="array">
                                        <label/>
                                        <value/>
                                    </numIndex>
                                    <numIndex index="1" type="array">
                                        <label>Label 1</label>
                                        <value>1</value>
                                    </numIndex>
                                </items>
                            </config>
                        </selectSingleColumn>
                        <!-- test comment 2 -->
                            <selectSingleColumn2>
                                <config>
                                    <type>select</type>
                                    <renderType>selectSingle</renderType>
                                    <items type="array">
                                        <numIndex index="0" type="array">
                                            <label/>
                                            <value/>
                                        </numIndex>
                                        <numIndex index="1" type="array">
                                            <label>Label 1</label>
                                            <value>1</value>
                                        </numIndex>
                                    </items>
                                </config>
                            </selectSingleColumn2>
                            <!-- test comment 3 -->
                                <selectSingleColumn3>
                                    <config>
                                        <type>select</type>
                                        <renderType>selectSingle</renderType>
                                        <items type="array">
                                            <numIndex index="0" type="array">
                                                <label/>
                                                <value/>
                                            </numIndex>
                                            <numIndex index="1" type="array">
                                                <label>Label 1</label>
                                                <value>1</value>
                                            </numIndex>
                                        </items>
                                    </config>
                                </selectSingleColumn3>
                            </el>
                        </ROOT>
                    </sDEF>
                </sheets>
            </T3DataStructure
@simonschaufi
Copy link
Collaborator

That is a bug in a third party library that we use. See shanethehat/pretty-xml#11. I hope this bug will be fixed there soon.

@andreaswolf
Copy link
Owner

I tried fixing it by myself, but did not manage to, since the library only handles opening/closing tags correctly, but not self-closing tags (or comments) AFAICS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants