-
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
Allow <style>
and <script>
tags to be unformatted
#494
Conversation
This looks good but needs some tests. Please add those and we'll merge. |
Can you give me some pointers on how to do that? |
There's a tests file that runs the beautifier over various inputs. See 219a44e for example. |
@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']; |
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.
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.
Addressed your comments with a2f7f75. |
Okay, last thing - please rebase your commits in this PR into a single commit. |
Done! Hope it's OK now. |
Allow <style> and <script> tags to be unformatted
<style>
and <script>
tags to be unformatted
Allow do not format 'script' and 'style' tags if they are set in the "unformatted" property from the configuration object.