Javascript-html Tidy can't display script tags properly?

Source: Internet
Author: User
Tags script tag tidy
I'm using HTML Tidy written by PHP, but one of the JavaScript stringsThe HTML Tidy output code is as follows: "'"' Above willInterpreted as part of the script. Then it adds aDisables the opening of labels. I tried to use the HTML Tidy to fix the problem, but the results still show that the error is running. How do I solve this problem?

Original problem: HTML Tidy fails on script tag in JavaScript string literal

Reply content:

I'm using PHP's HTML Tidy, but one of the "HTML Tidy output codes on the JavaScript string is as follows:" "The interpreter is part of the script. Then it adds a ban to open the label. I tried to use the HTML Tidy to fix the problem, but the results still show that the error is running. How do I solve this problem?

Original problem: HTML Tidy fails on script tag in JavaScript string literal

Answer: Arch
Based on experience, I think you can use//' <\/script> ' to control an algorithm to prevent this error from happening:

The clean-up algorithm is as follows:

      

I think it might be because the clean-up algorithm detects two strings. The separation < with/script> makes the second one undetectable so that it adds another at the end of the code.
So, I ventured to guess that there is no if statement in the entire algorithm to determine if there is any in the comment. So, if necessary, you can add another <\/script> string to the JavaScript comment, allowing the entire algorithm to identify two of them.

Answer: Herrserker
Instead of writing the script tag in a sentence, use the collocated string to express it:

Result Cleanup code:

        

Answer: Chris G
I think it's better to create a script tag using the following method:

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.