avatar MarkA Pro Oct 27. 2009. 1:28 am
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)
avatar Martin Hložek Oct 27. 2009. 3:25 am
Wow! Really great! Now I can use aC as our knowledge-base system. Thank you very much.
avatar mvas Nov 4. 2009. 3:26 am
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.
avatar jono Nov 4. 2009. 4:18 am
"In the comment box surround your code with one of following tags <syh>CODE GOES HERE</syh>…"

Does this work for discussion comments? If so, can you point me to a thread that outlines how to get TinyMCE's HTML view working in aC?
avatar MarkA Pro Nov 4. 2009. 1:08 pm
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!
}

</syh>
avatar jono Nov 4. 2009. 2:48 pm
I only see a WYSIWYG view in TinyMCE - how do I enable the HTML view for comments?
avatar MarkA Pro Nov 4. 2009. 3:47 pm
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.
avatar Panagiotis K. Dev Nov 4. 2009. 3:57 pm
Very nice and useful! I was looking for something like that!

My problem now is that it's not working for me :/

I downloaded the mvas's module and I edited the js.php file and added:

ASSETS_PATH . '/modules/syntaxhighlight/javascript/main.js',

at the end of $files array but I don't see any difference on the wysiwyg editor.

The block of array looks like this:

*Removed to not confuse anybody*
Aviant™ | Zend PHP 5 Certified Engineer
PHP Development / Symfony 2 / Zend Framework / JavaScript / HTML5 / CSS3
Online CV: panosru.com
avatar Panagiotis K. Dev Nov 4. 2009. 4:00 pm
Mark, since `<` and `>` tags are striped out and converted to &lt; and &gt; how is it possible identify anything between <syh> and </syh> ?

EDIT:
Now I saw in the source that you are looking for &lt;syh&gt; instead of <syh>. Wouldn't be easier or better to search something between [syh] and [/syh] ? I think it would be much nicer.
Aviant™ | Zend PHP 5 Certified Engineer
PHP Development / Symfony 2 / Zend Framework / JavaScript / HTML5 / CSS3
Online CV: panosru.com
avatar MarkA Pro Nov 4. 2009. 4:02 pm
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..
or Go To Next Page