I was working with html-tidy and a couple of my comments were moved from the head to the root of the document. Is there anyway to avoid this behavior?
(I'm trying to turn some really really bad markup into xhtml complaint code) Oh and additionally it uses an in-house developed semi-server-side scripting language that uses comments to place data within the html, very, very non-standard... I'd love to completely change it over...but you know how employers are...
Here is the problem:
Before Tidy:
<head>
...
<!-- BODY_ON_LOAD_SECTION -->
<script type="text/javascript" language="Javascript">
function init() {
openWin('BODY_ON_LOAD_SECTION_REFERENCE','','resizable=yes,width=400,height=400,left=50,top=50');
}
</script>
<!-- END_BODY_ON_LOAD_SECTION -->
</head>
After Tidy:
<script type="text/javascript" language="Javascript">
function init() {
openWin('BODY_ON_LOAD_SECTION_REFERENCE','','resizable=yes,width=400,height=400,left=50,top=50');
}
</script>
</head><!-- BODY_ON_LOAD_SECTION --> <!-- END_BODY_ON_LOAD_SECTION -->
They're comment. Do you really need them in the tidy version?
The only two options I see in tidy that relate to comments are hiding them and fixing bad comments so you may be out of luck.
来源:https://stackoverflow.com/questions/537112/html-tidy-dont-move-those-comments