-
Notifications
You must be signed in to change notification settings - Fork 451
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
Weird spaces in JSX html tags #1018
Comments
@bitwiseman added |
I am not sure this issue is valid. If the original source sample contained tags with spaces separating the delimiters from the tag names then the tags are invalid, ex: |
The problem is original code did not have spaces. But as soon as beautification is run it turns into that. What I would've expected is shown under the Expected Results. |
AFAIK out of the box atom-beautify uses |
If i run
|
No, Atom-Beautify does not use a .prettydiffrc file. Atom-Beautify uses the .jsbeautifyrc file for a bunch of beautifiers including Pretty Diff. I need to look into why you cannot choose Pretty Diff as a beautifier for JSX. |
I don't see JSX in the grammar selection list. Beautification works correctly in Pretty Diff if you change the language selection to JavaScript. The code is probably saved with a |
Yes it is selected as the one and only beautifier for JSX. I think you can see that from the debug info as well. |
@Glavin001 Any idea about #1018 (comment) Things I have discovered in this thread:
There is probably something here that I am not following correctly. |
After installing Atom package
|
I cannot reproduce this and I remember that I had similar problems before installing JSX support. |
May be thats the trick .. il give it ago. Yes im using atom as well On Fri, 17 Jun 2016, 21:53 Teemu Sirkiä notifications@github.com wrote:
|
@nixgadget did you manage to solve this? |
@ttsirkia I cant seem to reproduce this issue anymore. I think we are ok to close it. |
Awesome! Thanks guys. |
I have the same issue with @nixgadget. If I install |
Me too. And it is really annoying, because it also inserts whitespaces between tags - leading to lots of "validateDOMNesting(...): #text cannot appear as a child of " (or tbody, etc.) warnings... |
Hi all, thanks for reopening this. To make it easier to track this down (or point me to a simple config solution) I'll provide some additional information: Problem: Both beautyfiers (i.e. JS Beautify and Pretty Diff) insert whitespaces inside the tags as well as between tags - at least the second of which is obviously not tolerated by react. I have difficulties to believe that I am only the third one (after @nixgadget and @sangdth) who encounters this problem... Installed Community Packages:
atom-beautify offers the following default beautifiers in
Original Code from Tutorial To make sure it was not my own code that caused the problem I used the following code (fragment shown below): https://facebook.github.io/react/docs/thinking-in-react.html
Result using Pretty Diff as Default Beautifier
Result using JSBeautify as Default Beautifier
Warnings in Firebug:
... and the same with tbody, etc. See facebook/react#5071 and facebook/react#7515 where spicyj added a line comment 12 days ago:
So one of the beautifiers (JSBeautify) produces code like a broken pile of Mikado pick-up sticks, while Pretty Diff does exactly of what spicyj says it is not allowed: insert whitespace between tags on a single line... PS: @sangdth: I also tried language-babel package (with react package disabled!) and stumbled upon similar problems - even with the most basic tutorial code. Am I missing sth important? |
@achimbode Have you set enabled e4x/jsx support in JSBeautify in atom-beautify? |
I'm still unable to reproduce this problem. Here is my debug gist: |
Make sure that correct language is set to the editor before using atom-beautify (Ctrl+Shift+L -> JavaScript (JSX)) |
Hi all, @ttsirkia Ctrl+Shift+L only had Babel ES6 JavaScript on offer, which was apparently selected by the Auto Detect mode. I tried to find what actually caused the problems in the beginning, but I am not sure after all these changes. After some fiddling I found that I probably had set the file extension to *.js instead of *.jsx - at least this is the only way of reproducing the damaged formatting. |
The problem is most likely related to setting the language to |
@prettydiff I did a pull request #1068 that adds my language-babel grammar |
@prettydiff's beautifier and JS-Beautify likely support most, if not all of those already. The only thing missing would be mapping the language grammars for Atom to the appropriate language in Atom-Beautify. I'd recommend adding es2015, es2016, ESNext grammars to JavaScript language file in Atom-Beautify and JSX grammar to JSX language, if it is missing. However, I'm not sure about Flow. @prettydiff thoughts on supporting Flow? |
Is there an official link for flow? When I search for this I only see a static data type checker. |
@prettydiff Yes flow is Facebook's open sourced it static type checker that adds new syntax to JavaScript in a way that is similar to Typescript. You presumably found the doc, but the syntax definitions start here. |
@gandm I will be supporting Flow in the next release of Pretty Diff (2.1.10). It is similar to TypeScript, which Pretty Diff recently opened support for. |
@prettydiff Sounds good. One thing, flow files, unlike Typescript, do not use specific file extension, and will typically use |
Closing this as a Pretty Diff bug. |
Description
I have the default options for JSX and my
.jsbeautifyrc
is as follows,But in the following JSX code you can see weird spaces in tags e.t.c
Expected Results
The beautified code should have looked like:
Steps to Reproduce
Atom Beautify: Beautify Editor
Debug
Here is a link to the
debug.md
Gist: https://gist.github.com/nixgadget/3f50059d0710498ed5f15e8235b46ca5Checklist
so I know this is not a duplicate issue
debug.md
Gist to this issueThe text was updated successfully, but these errors were encountered: