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

Allow <style> and <script> tags to be unformatted #494

Merged
merged 1 commit into from
Sep 15, 2014
Merged

Allow <style> and <script> tags to be unformatted #494

merged 1 commit into from
Sep 15, 2014

Conversation

JoseGoncalves
Copy link
Contributor

Allow do not format 'script' and 'style' tags if they are set in the "unformatted" property from the configuration object.

@bitwiseman
Copy link
Member

This looks good but needs some tests. Please add those and we'll merge.

@JoseGoncalves
Copy link
Contributor Author

Can you give me some pointers on how to do that?
I'm not familiarized with JS testing...

@bitwiseman
Copy link
Member

There's a tests file that runs the beautifier over various inputs. See 219a44e for example.

@JoseGoncalves
Copy link
Contributor Author

@bitwiseman I've added the tests. Please check if it's OK.

@@ -1978,6 +1978,19 @@ function run_beautifier_tests(test_obj, Urlencoded, js_beautify, html_beautify,
opts.preserve_newlines = false;
bth('<div>\n\tfoo\n</div>', '<div>foo</div>');

opts.unformatted = ['script', 'style'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to save opt.unformatted and restore it after you're done. You might also put it closer to https://github.com/JoseGoncalves/js-beautify/blob/master/js/test/beautify-tests.js#L1790 , since those are also script tag tests.

Other than that, looks good.

@JoseGoncalves
Copy link
Contributor Author

Addressed your comments with a2f7f75.

@bitwiseman
Copy link
Member

Okay, last thing - please rebase your commits in this PR into a single commit.

@JoseGoncalves
Copy link
Contributor Author

Done! Hope it's OK now.

bitwiseman added a commit that referenced this pull request Sep 15, 2014
Allow <style> and <script> tags to be unformatted
@bitwiseman bitwiseman merged commit 678f1b2 into beautifier:master Sep 15, 2014
@bitwiseman bitwiseman changed the title Allow <style> and <script> tags to be unformatted Allow <style> and <script> tags to be unformatted Mar 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants