Hi, i was remaking syntax highlighter plugin based on javascript highlite. I got the problem that i need to include language (js/css) definitions when there is a code block.
If some user make a post with two blocks of code (ex: php), there is the error that include the php definitions (js/css) twice.
So, i make a plugin that take care about inclusion. An example use:
[code]
if (!empty($lang)) {
$classcode = ' class="'.$lang.'"';
if (run('mod:js:include','jquery.js')) {
if (run('mod:js:include', $chili_path . 'js/chili.js')) {
// main css
run('mod:js:inline', $chili_path . 'main.css');
// main ChiliBook options
run('mod:js:inline', $chili_path . 'main.js');
//run('mod:js:inline', dirname(__FILE__) . '/inc/recipes.js');
// better loading recipes and styles on demand
// include per language definition
run('mod:js:inline', $chili_path . 'inc/' . $lang . '.css');
run('mod:js:inline', $chili_path . 'inc/' . $lang . '.js');
}
}
} else {
[/code]
If a script file is already included return true, if something fail return false. Has the ability to include a script (css/js) as a link (js->src / css->import) or inline (script content inside the page). mod_js is bundled with jquery.
I use jquery to make things like clean search box on click, or hide/show comment form. See sample here: http://ajayu.memi.umss.edu.bo/ubuntu/weblog/esr-se-pasa-a-ubuntu
BTW, it's possible with mod_js to plugins make use of the same js library without including more than once.
You can download mod_js here: http://devel.memi.umss.edu.bo/rolando/hg/mod_js/archive/tip.zip
And test mod_chili (syntax highlighter, depends on mod_js) here: http://devel.memi.umss.edu.bo/rolando/hg/mod_chili/archive/tip.zip
mod_chili is a new syntax highlighter plugin that make the process of higlighting on user side, a different method that the old one (fshl) who makes the higlighting on server side. This is better for performance.
Language support: cpp, csharp, css, delphi, html, java, javascript, lotusscript, mysql (sql), php.
Sorry about my english.
PD: Could be possible make a spanish support community?
Keywords: javascript, jquery, plugin, syntax highlighter
