Syntax highlighter not working
Asked Answered
C

2

9

I am just following the instruction over here and its not working any help?

<script type="text/javascript" src="sh/src/shCore.js"></script>

<script type="text/javascript" src="sh/scripts/shBrushJScript.js"></script>

<link href="sh/styles/shCore.css" rel="stylesheet" type="text/css" />
<!--<link href="sh/styles/shCoreDefault.css" rel="stylesheet" type="text/css" />-->
<link href="sh/styles/shThemeDefault.css" rel="stylesheet" type="text/css" />

<pre class="brush: js">
    /**
     * SyntaxHighlighter
     */
    function foo()
    {
        if (counter <= 10)
            return;
        // it works!
    }
</pre>
<script type="text/javascript">
     SyntaxHighlighter.all()
</script>

Found some error in console don't know wt to do with it.

Uncaught ReferenceError: XRegExp is not defined shCore.js:123 Uncaught TypeError: Cannot read property 'Highlighter' of undefined shBrushJScript.js:45 Uncaught TypeError: Cannot read property 'all' of undefined test.php:21 Attr.specified is deprecated. Its value is always true.

Chiropractic answered 21/5, 2014 at 5:53 Comment(3)
Have you tried the web developer toolbar? Any errors in the JavaScript console here?Willett
Updated question with errorsChiropractic
@SkyKumar You're acessing the first file using sh/src/shCore.js and the scond using sh/scripts/shBrushJScript.js, I think they should be in the same directory.Polarity
E
2

I found this LINK

Try to keep all your local files for syntax highliter in same directory like this:

<script type="text/javascript" src="sh/src/shCore.js"></script>

<script type="text/javascript" src="sh/src/shBrushJScript.js"></script>

OR

<script type="text/javascript" src="sh/scripts/shCore.js"></script>

<script type="text/javascript" src="sh/scripts/shBrushJScript.js"></script>
Ebner answered 21/5, 2014 at 6:13 Comment(0)
W
0

I quickly made a simple html site to check your problem and it works for me:

<html>
<head>
    <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/shBrushJScript.js" type="text/javascript"></script>
    <link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <pre class="brush: js">
    /**
    * SyntaxHighlighter
    */
    function foo()
    {
        if (counter <= 10)
            return;
        // it works!
    }
    </pre>
    <script type="text/javascript">
        SyntaxHighlighter.all()
    </script>
</body>
</html>

So I'm pretty sure, you're having some referencing issue as the files in the <script> tag are not correctly referencing the local files. Try again with the remote files offered by the author of the script. Does it work then?

Willett answered 21/5, 2014 at 6:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.