In response to this post by me:
http://www.activecollab.com/forums/topic/5197/
I have created a simple way to use Syntaxhighlighter within AC .. and will post here for more brilliant to make improvements and make it better.
I hope you find it useful.
Version 1:
INSTALLATION STEPS
- Copy The "Syntaxhighlighter" directory to your project under:
/public/assets/javascript/
- Add the folowing lines to the js.php:
// BEGIN: SyntaxHighlighter
ASSETS_PATH . '/javascript/syntaxhighlighter/shCore.js',
ASSETS_PATH . '/javascript/syntaxhighlighter/shCustomOnLoad.js',
// END: SyntaxHighlighter
This is under the "$files = array();" statement.
USING
- In the comment box surround your code with one of following tags <syh>CODE GOES HERE</syh> this will activate the xml type.
- If you need to use other languages highlighter use one of the following:
- <syh:js>CODE GOES HERE</syh> for JavaScript
- <syh:csharp>CODE GOES HERE</syh>
- <syh:css>CODE GOES HERE</syh>
- <syh:text>CODE GOES HERE</syh>
- <syh:sql>CODE GOES HERE</syh>
- <syh:vb>CODE GOES HERE</syh>
- <syh:php>CODE GOES HERE</syh>
- <syh:as3>CODE GOES HERE</syh>
TODO'S:
- Need to check if user has entered the closing tag.
- Add more language highlighter support: http://alexgorbatchev.com/wiki/SyntaxHighlighter:Brushes
- Copy icon (swf) not working.
- I think this should be integrated as a model for easy installation (not an a expert in php.. sorry)
Hi, I have made your stuff into installabe modul. It needs to be little improved, but in this moment it works. I renamed shCustomOnLoad.js to main.js and copy content of shCore.js into that main.js. Then I just change some pathes to script to make it work. Don't hestiate to contact me.
Thanks mvas.. that is a lot more cleaner .. I have few things to update in the code i.e. checking if all <syh>tags are closed.. I'll work on it as soon as I get a chance to and hopefully post an update then.
Jono, syh should work for comments, the important thing is that you around your code with the syh tags.. i.e.
<syh:javascript>
/**
* Comment here
*/
function foo()
{
// it works!
}
This isn't a html source code.. you have to type it in the same WYSIWYG view. That is the whole point of this.. since we didn't want to manipulate the core files for ac... this code will read your page after it's done loading and then apply Syntaxhighlighter to sections surrounded by <syh> tags as mentioned.
Mark, since `<` and `>` tags are striped out and converted to < and > how is it possible identify anything between <syh> and </syh> ?
EDIT:
Now I saw in the source that you are looking for <syh> instead of <syh>. Wouldn't be easier or better to search something between [syh] and [/syh] ? I think it would be much nicer.
I believe with mavs model, you don't need to adjust any code .. it's all built in (I haven't tested though) but that's the whole point of have it as installable model.. so just install the model and see if that works.
as for using [ instead.. of < .. I that's a good idea, I'll try to update that next time I adjust the code..
http://www.activecollab.com/forums/topic/5197/
I have created a simple way to use Syntaxhighlighter within AC .. and will post here for more brilliant to make improvements and make it better.
I hope you find it useful.
Version 1:
INSTALLATION STEPS
- Copy The "Syntaxhighlighter" directory to your project under:
/public/assets/javascript/
- Add the folowing lines to the js.php:
// BEGIN: SyntaxHighlighter
ASSETS_PATH . '/javascript/syntaxhighlighter/shCore.js',
ASSETS_PATH . '/javascript/syntaxhighlighter/shCustomOnLoad.js',
// END: SyntaxHighlighter
This is under the "$files = array();" statement.
USING
- In the comment box surround your code with one of following tags <syh>CODE GOES HERE</syh> this will activate the xml type.
- If you need to use other languages highlighter use one of the following:
- <syh:js>CODE GOES HERE</syh> for JavaScript
- <syh:csharp>CODE GOES HERE</syh>
- <syh:css>CODE GOES HERE</syh>
- <syh:text>CODE GOES HERE</syh>
- <syh:sql>CODE GOES HERE</syh>
- <syh:vb>CODE GOES HERE</syh>
- <syh:php>CODE GOES HERE</syh>
- <syh:as3>CODE GOES HERE</syh>
TODO'S:
- Need to check if user has entered the closing tag.
- Add more language highlighter support: http://alexgorbatchev.com/wiki/SyntaxHighlighter:Brushes
- Copy icon (swf) not working.
- I think this should be integrated as a model for easy installation (not an a expert in php.. sorry)