0

I am looking at http://alexgorbatchev.com/SyntaxHighlighter/manual/demo/html-script.html. It uses

<pre class="brush: php; html-script: true">

I want to use it with JavaScript instead.

<script type="syntaxhighlighter" class="brush: js;  html-script: true">
<![CDATA[
<html>
<body>
<script>
  /**
   * SyntaxHighlighter
   */
  function foo()
  {
      if (counter <= 10)
          return;
      // it works!
  }
</script> <!-- this </script> seems to confuse the syntax highlighter -->
</body>
</html>  
]]>
</script>

Notice I use "brush: js;". Unfortunately, it got confused with the "</script>" tag above.

How to deal with the above case?

Thanks in advance for your help.

UPDATE:

I use < pre /> method as mentioned on http://alexgorbatchev.com/SyntaxHighlighter/manual/installation.html

pion
  • 3,593
  • 6
  • 29
  • 41

1 Answers1

1

Don't forget shBrushXml.js.

This self-contained example is working:

<html>
<head>

<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"/>
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"/>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
SyntaxHighlighter.all();
</script>

</head>

<body>

<pre class="brush: js;  html-script: true">
<html>
<body>
<script>
  /**
   * SyntaxHighlighter
   */
  function foo()
  {
      if (counter <= 10)
          return;
      // it works!
  }
</script>
</body>
</html>  
</pre>

</body>
</html>
galli2000
  • 478
  • 5
  • 14