We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44580
    • 189 Posts
    I'm trying to use SyntaxHighlighter inside Articles and I'm getting some weird formatting. This is my markup:
    <pre class="brush: js">
    function path()
    {
      var args = arguments,
          result = []
          ;
           
      for(var i = 0; i < args.length; i++)
          result.push(args[i].replace('@', '/pub/sh/current/scripts/'));
           
      return result
    };
    </pre>

    This is the result I'm getting in my blog page:

    If I doubleclick on the code (as if I was going to copy it), the code reformats correctly - but only until I click again - at which point it goes back to the original format.
    If I view page source, it looks like this:
    <pre class="brush: js">
    function path()
    {
      var args = arguments,
          result = []
          ;
           
      for(var i = 0; i < args.length; i++)
          result.push(args[i].replace('@', '/pub/sh/current/scripts/'));
           
      return result
    };
    </pre>

    Which is exactly what I would expect if it was working. I have not made any changes to Articles templates nor any css and I am getting similar results on other pages. I am perplexed. Any help would be greatly appreciated. Thanks, Robert.
      • 3749
      • 24,544 Posts
      Are you using the SH snippet or the plugin (not sure it would make any difference).

      What happens if you use:

      <pre class="brush: php">
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 44580
        • 189 Posts
        Tried both snippet and plugin (currently plugin) - same deal. Tried js, php and xml brushes. No change.
          • 44580
          • 189 Posts
          Oops. My bad. Turns out I had made a change to the ArticleTemplate that I had forgotten about (some additional stylesheets). One of these must have been the culprit as it was fixed as soon as I removed them.

          Sorry for wasting your time BobRay. Appreciate the help.
            • 3749
            • 24,544 Posts
            I'm glad you got it sorted. smiley
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting