我在看http://alexgorbatchev.com/SyntaxHighlighter/manual/demo/html-script.html。它使用
<pre class="brush: php; html-script: true">
我想用JavaScript代替它。
<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>
注意我使用“brush:js;”。
不幸的是,它与上面的“</script>
”标签混淆了。
如何处理上述情况?
提前感谢您的帮助。
更新:
我使用&lt; pre /&gt;方法,如http://alexgorbatchev.com/SyntaxHighlighter/manual/installation.html
所述答案 0 :(得分:1)
不要忘记shBrushXml.js
。
这个自包含的示例正在运行:
<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>