TriggerHappy
...
- Reaction score
- 341
Ok i searched this site for how to implement jass tags into a vbulletin site and i found a parser?
how would i use this to implement the jass tags?
PHP:
<?php
// Jass Highlighter
// Written by Asger Feldthaus (KaTTaNa)
if(!defined('JASS_HIGHLIGHTER_INCLUDED')) // Make sure it is only included once.
{
define('JASS_HIGHLIGHTER_INCLUDED', true);
function FixWord($word) {
$Blocks =
" constant native function takes returns endfunction if then else elseif endif loop endloop exitwhen ( ) [ ] ";
$Keywords =
" call set local return not and or ";
$Values =
" true false null ";
$Types =
" nothing array string integer real code boolean handle event player widget unit destructable item ability buff ".
"force group trigger triggercondition triggeraction timer location region rect boolexpr sound conditionfunc filterfunc ".
"unitpool itempool race alliancetype racepreference gamestate igamestate fgamestate playerstate playergameresult ".
"unitstate aidifficulty eventid gameevent playerevent playerunitevent unitevent limitop widgetevent dialogevent ".
"unittype gamespeed gamedifficulty gametype mapflag mapvisibility mapsetting mapdensity mapcontrol playerslotstate ".
"volumegroup camerafield camerasetup playercolor placement startlocprio raritycontrol blendmode texmapflags effect ".
"effecttype weathereffect terraindeformation fogstate fogmodifier dialog button quest questitem defeatcondition timerdialog ".
"leaderboard multiboard multiboarditem trackable gamecache version itemtype texttag playerscore lightning pathingtype image ubersplat ".
"attacktype damagetype weapontype soundtype ";
if (strpos($Blocks, " ".$word." ")!== false) {
return "<b>".$word."</b>";
}
elseif (strpos($Keywords, " ".$word." ")!== false) {
return "<span style=\"color: Navy;\">".$word."</span>";
}
elseif (strpos($Values, " ".$word." ")!== false) {
return "<span style=\"color: Maroon;\">".$word."</span>";
}
elseif (strpos($Types, " ".$word." ")!== false) {
return "<span style=\"color: rgb(50, 100, 200);\">".$word."</span>";
}
return $word;
}
function HighlightJass($text, $bb=false) {
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
$special = "[]()";
$str = "\"'";
$trans = Array(">" => ">", "<" => "<", "&" => "&");
if (!$bb)
{
$text = strtr($text, $trans);
}
else
{
// Do some backwards working
$tr = array('(' => '(',
')' => ')',
'[' => '[',
']' => ']',
'"' => '"');
$text = strtr($text,$tr);
}
$result = "";
$comment = 0;
$Lines = explode("\n", $text);
$anchors = array();
$n = 0;
// First, find all functions and place an anchor there
foreach($Lines as $Line)
{
// Leave anchor here?
$reg = array();
$anchors[$n] = '';
if (ereg('^ *(constant )? *(function|native) *([a-zA-Z_][a-zA-Z_0-9]*) *takes', $Line, $reg))
{
$l = max(0, $n-12);
$anchors[$l] .= '<a name="'.strtolower($reg[3]).'"></a>';
}
$n++;
}
$n = 0;
foreach($Lines as $Line)
{
$result .= $anchors[$n];
$Line = rtrim($Line);
if ($isString) {
$result = $result . "</span>";
}
$stop = strpos($Line, "//");
if ($stop === false) {
$stop = strlen($Line);
$comment = 0;
} else {
$comment = 1;
}
$i = 0;
$word = "";
$isString = 0;
$stringStarter = "";
$slashed = 0;
// Highlight
while ($i < $stop) {
$c = substr($Line, $i, 1);
$i += 1;
if ($isString) {
$result = $result . $c;
if ($c == "\\") {
$slashed = ($slashed)? 0:1;
} elseif (($c == $stringStarter) && !($slashed)) {
$result = $result . "</span>";
$isString = 0;
} else {
$slashed = 0;
}
} else {
// If normal character
if (strpos($chars, $c) !== false) {
$word = $word . $c;
// If bracket
} elseif (strpos($special, $c) !== false) {
$result = $result . FixWord($word) . FixWord($c);
$word = "";
// If string
} elseif (strpos($str, $c) !== false) {
$result = $result . FixWord($word) . "<span style=\"color: blue\">" . $c;
$slashed = 0;
$word = "";
$isString = 1;
$stringStarter = $c;
// If other character
} else {
$result = $result . FixWord($word) . $c;
$word = "";
}
} // if ($isString)
}
$result = $result . FixWord($word);
// Add comment
if ($comment) {
$result = $result . "<span style=\"color: green;\">".strstr($Line, "//")."</span>";
}
// Add linebreak
$result = $result . '<br />';
$n++;
}
$result = substr($result, 0, strlen($result)-1); // Remove last linebreak
if ($bb)
{
$tr = array('(' => '(',
')' => ')',
'[' => '[',
']' => ']');
$result = strtr($result, $tr);
}
return $result;
}
}
?>
how would i use this to implement the jass tags?