Copy link to clipboard
Copied
Using RH 2022, Version 2022.0.346
In the RH 2022 HTML editor, I am editing my Topic Layout page. I am looking at this code that has zero errors.
I compile and view my output and am happy to see that the URL of the current page displays in the output, meaning my test worked.
I decide to hide the lines that start with < h2 > through the ending < / script > tag because I may want it for future reference but I don't want to include that section "now" so I add the <!—and --> code before the < h2 > and after the < / script > tag. When I do that, the HTML editor claims I have to have a start tag for the < / script > tag, saying that the tag must be paired:
Why did the original code not generate an error and by hiding that bit of code, I see an error?
For a parser, the comment you start in line 29 already ends in line 34, not in line 36 as you intend.
What you are doing here is trying to nest the existing comment (line 32 to 34) into a parent comment (line 29 to 36). However, nested comments of the same notation are generally not possible.
Remove the commenting inside the CDATA section on lines 32 and 34, and it will work as you intend:
<div data-region="footer">
<p>(…)</p>
<!-- <h2>Test</h2>
<script type="text/javascript">
//<!
...
Copy link to clipboard
Copied
You can't nest comments in HTML. You need to close the comment you added before the <h2> tag before you can start the comment within the script. Also, by leaving it open following the </h2>, you've effectively commented out the opening <script> tag.
Copy link to clipboard
Copied
For a parser, the comment you start in line 29 already ends in line 34, not in line 36 as you intend.
What you are doing here is trying to nest the existing comment (line 32 to 34) into a parent comment (line 29 to 36). However, nested comments of the same notation are generally not possible.
Remove the commenting inside the CDATA section on lines 32 and 34, and it will work as you intend:
<div data-region="footer">
<p>(…)</p>
<!-- <h2>Test</h2>
<script type="text/javascript">
//<![CDATA[
document.write("This page is located at: " + document.URL);
//]]>
</script>
-->
<hr align="center" />
</div>
If you want to comment out a line of code inside a JavaScript preceed it with "// (code)".
If you want to comment multiple lines of code inside a JavaScript wrap them into /* (code) */.
Like this:
<div data-region="footer">
<p>(…)</p>
<!-- <h2>Test</h2>
<script type="text/javascript">
//<![CDATA[
// document.write("This page is located at: " + document.URL);
//]]>
</script>
-->
<hr align="center" />
</div>
Or this:
<div data-region="footer">
<p>(…)</p>
<!-- <h2>Test</h2>
<script type="text/javascript">
//<![CDATA[
/*
document.write("This page is located at: " + document.URL);
document.write("This is just another line.");
*/
//]]>
</script>
-->
<hr align="center" />
</div>
Hope that helps.
Copy link to clipboard
Copied
Okay - I see what I was doing wrong - figured it was something silly...
Copy link to clipboard
Copied
Not silly at all! This is a quite advanced scenario and a special case, where you need some deeper HTML knowledge + JavaScript knowledge + the combinatio of both and how they interact with/depend on each other with their different notations for comments. Easy to run into this even for experienced experts 😉
Please remember to mark one of the answers that helped you solve the problem as "Correct Answer"