简体   繁体   English

正确解析html注释

[英]parsing html comments correctly

Is there a good reference on how to parse html comments robustly especially where the html contains javascript which could break the comment 关于如何健壮地解析html注释是否有很好的参考,特别是在html包含可能破坏注释的javascript的情况下

for example: 例如:

         <!--
         <script type="text/javascript">
         for( var i = 10; i > 0; i-- ) {
                      if( myar[i].status > 3 ) {
                                   ntlp++;
                      }
         }
         </script>
         -->

the two minus's and the greater than 3 in the script could be considered a concatenation that is interpreted as '-->' ( if you follow the html/sgml spec correctly ). 脚本中的两个减号和大于3的字符串可以被认为是解释为“->”的串联(如果您正确遵循html / sgml规范)。

Anyway, is there a list of rules/gotchas to process all this ? 无论如何,是否存在处理所有这些的规则/陷阱列表? In C would be preferable, otherwise pseudo-code is great too. 在C中会更好,否则伪代码也很棒。

thanks 谢谢

Ashod 阿肖德

If you meet <!-- in the code, everything further is a comment until --> . 如果您在代码中遇到<!-- ,则进一步的注释都是--> What other rules are needed? 还需要其他哪些规则?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM