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

Incorrect indentation for elements whose names are case-insensitive matches to HTML self-closing tags #68

Open
asazernik opened this issue May 9, 2016 · 2 comments
Labels

Comments

@asazernik
Copy link

Example output:

          <Row>
            <Col xs={ 2 }> Categories:
            </Col>
            <Col xs={ 10 }>
            <TagSelector valueLink={ this.linkImmutableState(["deets", "tags"]) } tagType="ingredients" />
            </Col>
          </Row>

In HTML, <col> is a singleton tag: it can't contain any content, and if it doesn't have the closing '/' it's still a complete tag on its own. Because of this, js-beautify's HTML beautifier doesn't indent the line after any tag that shares a name with one of these singleton tags. Even if the "self-closing" tag is closedlater

However, this is not a feature of JSX, even when representing native DOM tags; JSX follows the rules of strict XML in this regard. The solution is probably to use a beautifier library built for XML rather than HTML to deal with the JSX bits.

This tends to pop up a lot in practice, since many HTML singleton tag names are pretty common to use as React component names e.g. col, input, link, command, etc.

@royriojas royriojas added the bug label May 9, 2016
@royriojas
Copy link
Owner

Thanks @asazernik for reporting. Will investigate other xml formatters that might do a better job.

Regards

@jamesvillarrubia
Copy link

Bump on this. Is extra annoying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants