-
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
Add content_unformatted config to avoid formatting content of an element (fix #906) #1080
Conversation
@arai-a - Thanks for submitting. Finally, please format your multi-line test inputs or outputs like this to make them easier to understand: tests: [{
fragment: true,
input: '<html><body><h1>A</h1><script>if(1){f();}</script><style>.a{display:none;}</style></body></html>',
output: [
'<html>',
'<body>',
' <h1>A</h1>',
' <script>if(1){f();}</script>',
' <style>.a{display:none;}</style>',
'</body>',
'',
'</html>'
]
}] |
c36213a
to
b3798f1
Compare
rebased onto latest master and added tests from #1081 and it passed without any changes. |
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.
A few more tests needed and need to have pre
as part of the default. Once that is done, this looks good.
@@ -161,6 +163,7 @@ | |||
'acronym', 'address', 'big', 'dt', 'ins', 'strike', 'tt', | |||
'pre', | |||
]; | |||
content_unformatted = options.content_unformatted || []; |
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.
Please move 'pre'
from unformatted
, into the default for content_unformatted and add some tests for it based on #928.
name: "content_unformatted to prevent formatting content", | ||
description: "", | ||
options: [ | ||
{ name: 'content_unformatted', value: "['script', 'style', 'p', 'span', 'br']" } |
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.
Add some examples with <pre>
tag (as mentioned above).
Then please do the same inputs with the default content_unformatted
. It is important to understand how this changes the outputs.
b3798f1
to
32c8e6e
Compare
okay, moved pre to content_unformatted and added tests for pre and default options, |
Great, thanks. |
I don't see the missing newline issue, on osx, node v6.9.1. |
tested also on debian, nodejs v4.6.1, |
Thank you for your contributio. I hope you will continue to contribute beyond this one PR. |
thank you too for reviewing :) |
This fixes #906
The issue is that
unformatted
config is applied to following 3 places:while it's useful for inline elements, when one want to disable formatting only the content of the content, keeping newlines before/after it, the config cannot be used.
I added new
content_unformatted
config, that does only "content of the element" part.if
content_unformatted
one add "style" and "script" to this, their content is not formatted, while they still have newlines before/after them.config file:
output
I also added commandline option
--content_unformatted
, or-T
(the first character in 'content_unformatted' that wasn't used...), that can be used like--unformatted
.