-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Capture empty tags #1868
Capture empty tags #1868
Conversation
Added validations to prevent tagged literals from being modified
This reverts commit 95e29b8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice change.
test/data/javascript/tests.js
Outdated
' <a>', | ||
' <td>Hello</td>', | ||
' <td>World</td>', | ||
' </a>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be empty to actually test your change right?
' <a>', | |
' <td>Hello</td>', | |
' <td>World</td>', | |
' </a>', | |
' <>', | |
' <td>Hello</td>', | |
' <td>World</td>', | |
' </>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! I didn't see I hadn't changed it back, I will change this now
@@ -126,7 +126,7 @@ var Tokenizer = function(input_string, options) { | |||
html_comment_end: pattern_reader.matching(/-->/), | |||
include: pattern_reader.starting_with(/#include/).until_after(acorn.lineBreak), | |||
shebang: pattern_reader.starting_with(/#!/).until_after(acorn.lineBreak), | |||
xml: pattern_reader.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[\s\S]+?}|!\[CDATA\[[\s\S]*?\]\])(\s+{[\s\S]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{[\s\S]+?}))*\s*(\/?)\s*>/), | |||
xml: pattern_reader.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[\s\S]+?}|!\[CDATA\[[\s\S]*?\]\]|)(\s+{[\s\S]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{[\s\S]+?}))*\s*(\/?)\s*>/), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is clearer to say this group is optional, but that might cause the number groups to change, right?
This is not a suggestion, I'm just using that to show a clear diff.
xml: pattern_reader.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[\s\S]+?}|!\[CDATA\[[\s\S]*?\]\]|)(\s+{[\s\S]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{[\s\S]+?}))*\s*(\/?)\s*>/), | |
xml: pattern_reader.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[\s\S]+?}|!\[CDATA\[[\s\S]*?\]\])?(\s+{[\s\S]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{[\s\S]+?}))*\s*(\/?)\s*>/), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see what you mean, but yes it causes other problems
While fixing this issue I saw something that could be another issue:
Output:
Although if I changed to indent to 2 spaces per indent, the output would be unchanged from the first input which is the expected output. This is because the input is tabbed with 2 spaces. Maybe the error is because of the single tags, although I haven't looked into it yet |
I am still having the issue of empty <> </> tags in my jsx being incorrectly formatted. Do I need to change something manually, or add another setting to the .jsbeautifyrc file to incorporate this change? Before format:
After format:
|
@Zetrick |
Description
Updated xml to capture empty tags in both python and JS files
master
)Fixes Issue: #1854
Before Merge Checklist
These items can be completed after PR is created.
(Check any items that are not applicable (NA) for this PR)