06-19-2004, 09:46 AM
I've updated the generic syntax highlighter for QBnews. It's now up to 5,800% faster and doesn't use the database (downside below). But more importantly, it's better and it supports 6 languages: PHP, QuickBASIC (QBasic as well by extension), CSS, SQL, Java and C.
How do you use it? The same way as before: [syntax="language"] ... [/syntax], where at this time language is the one of the literal strings "php", "qbasic", "css", "sql", "java" or "c" (case insensitive). If you try to highlight a language that doesn't exist nothing will happen.
Here are a few demos:
[syntax="qbasic"]IF ( 1 = 2) THEN
PRINT "hello, world!"
END IF
FUNCTION foo (r%)
' comment with two spaces
' comment with no spaces
END FUNCTION
rem autocaps too: just quote this post to see
for i = 1 to 30 step 2
locate i, i mod 2
print "GeSHi!!!!!!!"
next i
do: loop until inkey$ <> ""
cls[/syntax]
A function in the phpBB template class:
[syntax="php"] /**
* Block-level variable assignment. Adds a new block iteration with the given
* variable assignments. Note that this should only be called once per block
* iteration.
*/
function assign_block_vars($blockname, $vararray)
{
if (strstr($blockname, '.'))
{
// Nested block.
$blocks = explode('.', $blockname);
$blockcount = sizeof($blocks) - 1;
$str = '$this->_tpldata';
for ($i = 0; $i < $blockcount; $i++)
{
$str .= '[\'' . $blocks[$i] . '.\']';
eval('$lastiteration = sizeof(' . $str . ') - 1;');
$str .= '[' . $lastiteration . ']';
}
// Now we add the block that we're actually assigning to.
// We're adding a new iteration to this block with the given
// variable assignments.
$str .= '[\'' . $blocks[$blockcount] . '.\'][] = $vararray;';
// Now we evaluate this assignment we've built up.
eval($str);
}
else
{
// Top-level block.
// Add a new iteration to this block with the variable assignments
// we were given.
$this->_tpldata[$blockname . '.'][] = $vararray;
}
return true;
}[/syntax]
The top of subSilver.css
[syntax="css"]/*
The original subSilver Theme for phpBB version 2+
Created by subBlue design
http://www.subBlue.com
*/
/* General page style. The scroll bar colours only visible in IE5.5+ */
body {
background-color: #E5E5E5;
scrollbar-face-color: #DEE3E7;
scrollbar-highlight-color: #FFFFFF;
scrollbar-shadow-color: #DEE3E7;
scrollbar-3dlight-color: #D1D7DC;
scrollbar-arrow-color: #006699;
scrollbar-track-color: #EFEFEF;
scrollbar-darkshadow-color: #98AAB1;
}
/* General font families for common tags */
font,th,td,p { font-family: Verdana, Arial, Helvetica, sans-serif }
a:link,a:active,a:visited { color : #006699; }
a:hover { text-decoration: underline; color : #DD6900; }
hr { height: 0px; border: solid #D1D7DC 0px; border-top-width: 1px;}
/* This is the border line & background colour round the entire page */
.bodyline { background-color: #FFFFFF; border: 1px #98AAB1 solid; }
/* This is the outline round the main forum tables */
.forumline { background-color: #FFFFFF; border: 2px #006699 solid; }
/* Main table cell colours and backgrounds */
td.row1 { background-color: #EFEFEF; }
td.row2 { background-color: #DEE3E7; }
td.row3 { background-color: #D1D7DC; }[/syntax]
More information can be found at the GeSHi website, including a demo form for you to explore the power of GeSHi (including uploading your own files, changing colours and styles etc).
I think this is a great improvement over the current version, and I urge you guys to use this when you can. I'm most greatful to all who do test this - your feedback will make GeSHi faster and better. And if you make a new language file for GeSHi (see the website) you'll get your name up in lights
Have fun
How do you use it? The same way as before: [syntax="language"] ... [/syntax], where at this time language is the one of the literal strings "php", "qbasic", "css", "sql", "java" or "c" (case insensitive). If you try to highlight a language that doesn't exist nothing will happen.
Here are a few demos:
[syntax="qbasic"]IF ( 1 = 2) THEN
PRINT "hello, world!"
END IF
FUNCTION foo (r%)
' comment with two spaces
' comment with no spaces
END FUNCTION
rem autocaps too: just quote this post to see
for i = 1 to 30 step 2
locate i, i mod 2
print "GeSHi!!!!!!!"
next i
do: loop until inkey$ <> ""
cls[/syntax]
A function in the phpBB template class:
[syntax="php"] /**
* Block-level variable assignment. Adds a new block iteration with the given
* variable assignments. Note that this should only be called once per block
* iteration.
*/
function assign_block_vars($blockname, $vararray)
{
if (strstr($blockname, '.'))
{
// Nested block.
$blocks = explode('.', $blockname);
$blockcount = sizeof($blocks) - 1;
$str = '$this->_tpldata';
for ($i = 0; $i < $blockcount; $i++)
{
$str .= '[\'' . $blocks[$i] . '.\']';
eval('$lastiteration = sizeof(' . $str . ') - 1;');
$str .= '[' . $lastiteration . ']';
}
// Now we add the block that we're actually assigning to.
// We're adding a new iteration to this block with the given
// variable assignments.
$str .= '[\'' . $blocks[$blockcount] . '.\'][] = $vararray;';
// Now we evaluate this assignment we've built up.
eval($str);
}
else
{
// Top-level block.
// Add a new iteration to this block with the variable assignments
// we were given.
$this->_tpldata[$blockname . '.'][] = $vararray;
}
return true;
}[/syntax]
The top of subSilver.css
[syntax="css"]/*
The original subSilver Theme for phpBB version 2+
Created by subBlue design
http://www.subBlue.com
*/
/* General page style. The scroll bar colours only visible in IE5.5+ */
body {
background-color: #E5E5E5;
scrollbar-face-color: #DEE3E7;
scrollbar-highlight-color: #FFFFFF;
scrollbar-shadow-color: #DEE3E7;
scrollbar-3dlight-color: #D1D7DC;
scrollbar-arrow-color: #006699;
scrollbar-track-color: #EFEFEF;
scrollbar-darkshadow-color: #98AAB1;
}
/* General font families for common tags */
font,th,td,p { font-family: Verdana, Arial, Helvetica, sans-serif }
a:link,a:active,a:visited { color : #006699; }
a:hover { text-decoration: underline; color : #DD6900; }
hr { height: 0px; border: solid #D1D7DC 0px; border-top-width: 1px;}
/* This is the border line & background colour round the entire page */
.bodyline { background-color: #FFFFFF; border: 1px #98AAB1 solid; }
/* This is the outline round the main forum tables */
.forumline { background-color: #FFFFFF; border: 2px #006699 solid; }
/* Main table cell colours and backgrounds */
td.row1 { background-color: #EFEFEF; }
td.row2 { background-color: #DEE3E7; }
td.row3 { background-color: #D1D7DC; }[/syntax]
More information can be found at the GeSHi website, including a demo form for you to explore the power of GeSHi (including uploading your own files, changing colours and styles etc).
I think this is a great improvement over the current version, and I urge you guys to use this when you can. I'm most greatful to all who do test this - your feedback will make GeSHi faster and better. And if you make a new language file for GeSHi (see the website) you'll get your name up in lights
Have fun