Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

HTML Editor Question in RH 2022

Contributor ,
Dec 15, 2022 Dec 15, 2022

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.

prhmusic2_0-1671105383750.png

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:

prhmusic2_1-1671105383751.png

Why did the original code not generate an error and by hiding that bit of code, I see an error?

Views

308
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Dec 15, 2022 Dec 15, 2022

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">
    //<!
...

Votes

Translate
Participant ,
Dec 15, 2022 Dec 15, 2022

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.

 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Dec 15, 2022 Dec 15, 2022

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 15, 2022 Dec 15, 2022

Copy link to clipboard

Copied

Okay - I see what I was doing wrong - figured it was something silly...

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Dec 16, 2022 Dec 16, 2022

Copy link to clipboard

Copied

LATEST

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"

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
RoboHelp Documentation
Download Adobe RoboHelp