Skip to content

Loading…

Tags in javascript are being destroyed #117

Closed
irsdl opened this Issue · 7 comments

4 participants

@irsdl

Hi,
I grabbed this sample from www.bbc.co.uk website (cookie confirmation section on top):

<script type="text/html" id="test">
<![CDATA[ <div id="mytag"> <h2> Test </h2> <p> We use cookies</p></div> ]]>
</script>

These tags will be completely destroyed if you try it in http://jsbeautifier.org/

@bitwiseman

Does anyone with more html experience have any thoughts on this? http://stackoverflow.com/questions/3302648/should-i-use-cdata-in-html5 seems to indicate that the correct way to do this is:

<script type="text/html" id="test">
//<![CDATA[ <div id="mytag"> <h2> Test </h2> <p> We use cookies</p></div> ]]>
</script>
@irsdl
@einars

An usable solution would be to not really care for CDATA worm–can in this case and update html beautifier to attempt to determine the "type" attribute of the script tags, and leave everything intact if it's not text/javascript (or empty): currently all scripts are passed to js-beautifier as-is.

@irsdl
@bitwiseman bitwiseman added this to the v1.5.2 milestone
@bitwiseman

Looks like this now fixed.

@bitwiseman bitwiseman closed this
@pdf

Looks like this is broken (still/again?)

@irsdl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.