Page 1 of 2

Syntax Highlighter extension

PostPosted: Sun Sep 05, 2010 4:12 pm
by hansfn
This is the discussion topic for the Syntax Highlighter extension.

Just released: version 0.2 (see log in extension zip for changes)

Visit http://extensions.pivotx.net/entry/41/syntax-highlighter for download and more info.

Re: Syntax Highlighter extension

PostPosted: Sun Sep 05, 2010 5:43 pm
by marius
Hi,

After having uploaded the Syntax Highlighter extension and changing some of it's settings, it doesn't work and I don't understand why (this already makes clear where the error most likely is ; ).

So I've got a post here with some Python code:
http://www.beteredingen.nl/?e=396
And I changed the entry so that the opening code tag now looks like this:
Code: Select all
<code class="brush:python">


I changed the file snippet_highlighter.php to allow 'plain' and 'python' brushes. When I check the source code of the page there are some lines at the start that suggest that this got through:
Code: Select all
<script type="text/javascript" src="/pivotx/extensions/syntaxhighlighter/scripts/shBrushPython.js"></script>


This is apparently not enough to get it going. What am I missing / doing wrong?

Cheers, Marius.

Re: Syntax Highlighter extension

PostPosted: Sun Sep 05, 2010 6:37 pm
by hansfn
Oh, I think there is a tiny problem with the paths - rename the directory pivotx/extensions/syntax-highlighter/ to pivotx/extensions/syntaxhighlighter/ (This is just a work-around.) I'll update the extension ASAP.

ADDED

Actually, a much, much better fix is to edit the file pivotx/extensions/syntax-highlighter/snippet_highlighter.php and change the line

Code: Select all
$path = $PIVOTX['paths']['extensions_url']."syntaxhighlighter/";

to

Code: Select all
$path = $PIVOTX['paths']['extensions_url']."syntax-highlighter/";

This is not a work-around ;-)

Re: Syntax Highlighter extension

PostPosted: Sun Sep 05, 2010 7:32 pm
by marius
Hi Hans,

Thanks for your quick reaction! I did as described in your second solution. The links to the .js files in the source code of the page now work. But the code is still shown without highlighting. More ideas?

Cheers, Marius.

Re: Syntax Highlighter extension

PostPosted: Sun Sep 05, 2010 8:08 pm
by habbekak
Does it work when you edit templates(template editor)?

Re: Syntax Highlighter extension

PostPosted: Sun Sep 05, 2010 8:34 pm
by marius
I guess you mean if I add some code to a template starting with <code class="brush:python">?
In that case: no. It's shown as code, but without highlighting.

Re: Syntax Highlighter extension

PostPosted: Sun Sep 05, 2010 9:02 pm
by hansfn
It seems you have to use pre instead of code. Please test - it worked for me testing PHP code.

ADDED

Confirmed - it's a bug in the extension documentation - SyntaxHighlighter only supports pre tags for code.

FINAL ADDITION

The path bug and the incorrect documentation is fixed in version 0.1.1 - see first post for download link.

Re: Syntax Highlighter extension

PostPosted: Mon Sep 06, 2010 7:07 am
by marius
Hans,

That works, thanks a bunch man!

Marius.

Re: Syntax Highlighter extension

PostPosted: Fri May 09, 2014 12:45 pm
by leandrocpo
Dear,

I am having problem with the Syntax Highlighter component. He's breaking the line every code word.

I made the following entry:
Code: Select all
<pre class="brush:css">
  body, td, pre {color:#000; font-family:Tahoma, Arial, Helvetica, sans-serif; }
  body {background:#FFF;}
  body.mceForceColors {background:#FFF; color:#000;}
  h1 {font-size: 2em}
  h2 {font-size: 1.5em}
  h3 {font-size: 1.17em}
</pre>


and is coming out as follows: http://codigoeprosa.6te.net/?e=7&previe ... e9b8183d28
I'm using version 2.3.9 Pivotx.

Re: Syntax Highlighter extension

PostPosted: Sat May 10, 2014 9:45 am
by Harm10
Hi! I tried your code on my own site and it comes out like attached.

So I guess there is something on your site that influences the display?
Are there any errors in the browser console?
Perhaps you can provide a life link to a page that displays this code?