Code: Select all
#
#-----[ FIND ]---------------------------------
#
$EMBB_keys = array(''
$EMBB_widths = array(''
$EMBB_values = array(''
Code: Select all
$EMBB_keys = array(''
Code: Select all
Multi_BBCode();
StalkR wrote: I installed, in this order : Multi BBcode 1.40c, then BBCode Buttons Organizer 1.4.0, then PHP Syntax Highlighter BBCode 3.0.3.
-=ET=- wrote: You don't install the right MODs.
PHP Syntax Highlighter 3.0.5 is Multiple BBCode 1.4.0c compliant.
PHP Syntax Highlighter 3.0.3 & 3.0.4 are both Multiple BBCode 1.2.1 & 1.3.0a compliant.
sander marechal wrote: Here's the core of my highlighter. It's a little long but that is because of the long list of keywords that C++ uses.
[...]
Code: Select all
// START CPP Syntax Highlighter MOD
/**
* CPP MOD
* Original code/function by phpBB Group
* Modified by JW Frazier / Fubonis < [email protected] > for PHP highlighting
* Modified again by KI / Martin Mädler < [email protected] > for nice C++ highlighting
*/
function bbencode_second_pass_cpp($text, $uid, $bbcode_tpl)
{
// split the post up and grab the code blocks
$code_start_html = $bbcode_tpl['cpp_open'];
$code_end_html = $bbcode_tpl['cpp_close'];
// build the md5-hash of an escaped backslash \\
// we need this for string highlighting later
$escaped_backslash_md5 = md5("\\\\\\\\");
$matches = array();
$match_count = preg_match_all("#\[cpp:1:$uid\](.*?)\[/cpp:1:$uid\]#si", $text, $matches);
// this array holds all the C++ keywords, which will be highlighted in blue
$cppcodearray = array
(
"#define", "defined", "#else", "#elseif", "#endif", "#if", "#ifdef",
"#ifndef", "#include", "#pragma", "#undef",
"const_cast", "dynamic_cast", "reinterpret_cast", "static_cast",
"_asm", "__asm", "__attribute", "__catch", "__declspec", "__fastcall",
"__finally", "__forceinline", "_inline", "__inline", "__interface",
"__int8", "__int16", "__int32", "__int64", "__property", "__published",
"__stdcall", "__try",
"asm", "bool", "break", "case", "catch", "char", "class", "const",
"continue", "default", "defined", "delete", "dllexport", "dllimport",
"do", "double", "else", "enum", "extern", "false", "float", "for", "friend",
"if", "inline", "int", "interface", "long", "mutable", "namespace", "new",
"operator", "private", "protected", "public", "register", "return",
"short", "signed", "static", "switch", "template", "this", "true",
"typedef", "typename", "try", "union", "unsigned", "using", "void",
"volatile", "wchar_t", "while"
);
for ($i = 0; $i < $match_count; $i++)
{
$before_replace = $matches[1][$i];
$after_replace = $matches[1][$i];
$str_to_match = "[cpp:1:$uid]" . $before_replace . "[/cpp:1:$uid]";
// First of all we need to replace all multiline comments with its approriate md5-hash
// This prevents highlighting keywords inside of a comment
// Later the hashes are again replaced by its corresponing multiline comment
$comment_multi_count = 0;
do
{
// preg_match, with a specific multiline comment regex
$result = preg_match("/(\/\*.*?\*\/)/s", $after_replace, $comment_multi);
if($result == 0)
break;// if no more comments are found, leave the loop
$comment_multi_arr[$comment_multi_count] = $comment_multi[1];// this array holds the comments
$comment_multi_md5[$comment_multi_count] = md5($comment_multi[1]);// this one holds the corresponding md5-hash
$after_replace = substr_replace($after_replace, $comment_multi_md5[$comment_multi_count], strpos($after_replace, $comment_multi_arr[$comment_multi_count]), strlen($comment_multi_arr[$comment_multi_count]));
$comment_multi_count += 1;
}
while(true);
// Here we need to replace all singleline comments with its approriate md5-hash
// by using the same method as seen before
$comment_single_count = 0;
do
{
// preg_match, this time with a specific singleline comment regex
$result = preg_match("/(\/\/.*)/", $after_replace, $comment_single);
if($result == 0)
break;// if no more accordances are found, leave the loop
$comment_single_arr[$comment_single_count] = $comment_single[0];
$comment_single_md5[$comment_single_count] = md5($comment_single[0]);
$after_replace = substr_replace($after_replace, $comment_single_md5[$comment_single_count], strpos($after_replace, $comment_single_arr[$comment_single_count]), strlen($comment_single_arr[$comment_single_count]));
$comment_single_count += 1;
}
while(true);
// In the next part we are going to find strings within the code
// strings are characterized by one double quotes (") on each end
// replace all escaped backslashes with its appropriate md5-hash
// otherwise an escaped backslash at the end of a string would
// be interpreted as an escaped double quote
// That would result in an oversized string
// Example 1:(we want to prevent such bugs)
// <span style='color: #00B0B0'>"We don't want this \\" here is some code"</span>beginning of a new string...
// Example 2:(that's the way it has to be)
// <span style='color: #00B0B0'>"We want this\\"</span><span style='color: #00B0B0'>"beginning of a new string...
$after_replace = preg_replace("/(\\\\\\\\)/",$escaped_backslash_md5,$after_replace);
// now we find all strings
// the look behind feature (?<!\\\\)\") in our regex enables us to find strings with
// escaped double quotes \"
// otherwise the string would close at the second double quote from the beginning
$string_cnt = preg_match_all("/(\".*?(?<!\\\\)\")/s", $after_replace, $strings, PREG_SET_ORDER);
if ($string_cnt > 0)
{
foreach ($strings as $string)
{
$after_replace = str_replace($string[0], md5($string[0]), $after_replace);
}
}
// lets come to the highlighting
// this highlights everything red which is between square brackets
$after_replace = preg_replace("/(\[)([^\]]*)(\])/", "\\1<span style='color: #FF0000'>\\2</span>\\3", $after_replace);
// merge the keyword-array to a big regex
$keyword_regex = "/(?<![A-Za-z0-9_])(" . implode("|", $cppcodearray) . ")(?![A-Za-z0-9_])/";
// highlight the keywords
$after_replace = preg_replace($keyword_regex, "<span style='color: #0000FF'>\\0</span>", $after_replace);
// its time to replace all hashes with its corresponing character strings
// perform multiline comment highlighting
for($count = 0; $count < $comment_multi_count; $count++)
{
$after_replace = str_replace($comment_multi_md5[$count], "<span style='color: #008000'>" . $comment_multi_arr[$count] . "</span>", $after_replace);
}
// perform singleline comment highlighting
for($count = 0; $count < $comment_single_count; $count++)
{
$after_replace = str_replace($comment_single_md5[$count], "<span style='color: #008000'>" . $comment_single_arr[$count] . "</span>", $after_replace);
}
// perform string highlighting
if ($string_cnt > 0)
{
foreach ($strings as $string)
{
$after_replace = str_replace(md5($string[0]), "<span style='color: #00B0B0'>" . $string[0] . "</span>", $after_replace);
}
}
// replace all escaped backslash hashes with escaped backslashes
$after_replace = preg_replace("/(" . $escaped_backslash_md5 . ")/","\\\\\\\\",$after_replace);
// replace 2 spaces with " " so non-tabbed code indents without making huge long lines.
$after_replace = str_replace(" ", " ", $after_replace);
// now replace 2 spaces with " " to catch odd #s of spaces.
$after_replace = str_replace(" ", " ", $after_replace);
// replace tabs with " " so tabbed code indents sorta right without making huge long lines.
$after_replace = str_replace("\t", " ", $after_replace);
// now replace space occurring at the beginning of a line
$after_replace = preg_replace("/^ {1}/m", " ", $after_replace);
// make first \r\n to vanish if it exists
$after_replace = preg_replace("/^(\r\n)*/", "", $after_replace);
// piece the post back together
$replacement = $code_start_html;
$replacement .= $after_replace;
$replacement .= $code_end_html;
$text = str_replace($str_to_match, $replacement, $text);
}
$text = str_replace("[cpp:$uid]", $code_start_html, $text);
$text = str_replace("[/cpp:$uid]", $code_end_html, $text);
return $text;
}
Code: Select all
#
#-----[ OPEN ]------------------------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]------------------------------------------------
#
$EMBB_widths = array(''
$EMBB_values = array(''
so does that mean i have to install Easymod aswell to be able to get the PHP BBcode working? If so i think it would be great and beter for people who just start with modding and stuff to make this process much easier and combine these projects into 1 project or 1 mod install file instead of 3 or more diffrent mod installs.PHP Syntax Highlighter 3.0.5 is Multiple BBCode 1.4.0c compliant.
Code: Select all
// Start add - PHP Syntax Highlighter BBCode MOD
// [PHP] and [/PHP] for posting PHP code in your posts.
$text = bbencode_second_pass_php($text, $uid, $bbcode_tpl);
// End add - PHP Syntax Highlighter BBCode MOD
Code: Select all
:D :) :( :o :? 8) :lol: