Colourizing transcripts... but on PHP instead!
Slightly off-topic, I used
Ulrika's transcript colourizer to post transcripts online; it has the advantage of splitting up pieces of a transcript to properly format the code in "chunks" to be easily posted on the forums.
Alas, Ulrika's site has been down often, and yesterday I was desperate, so I thought to create my own PHP script instead. Feel free to use it; it's released on an "attribution" license of Creative Commons (do whatever you wish with it, but quote me

).
I'm not a programmer, so I guess lots of things could be done more efficiently; you're welcome to laugh at my amateurish accomplishments

If you don't have a webserver with PHP to try this out, you can test it
here. Notice that you might need to tweak the CSS styles for your own purpose, but I guess the defaults will work well.
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="css/styles.css" type="text/css" media="all" />
<meta name="author" content="Gwyneth Llewelyn" />
<meta name="copyright" content="(cc) 2006 by Gwyneth Llewelyn. Some rights reserved." />
<title>Gwyn's Colourizer PHP Script</title>
</head>
<body>
<h1>Gwyn's Colourizer PHP Script</h1>
<?php
// Simple PHP colour-coding script for meeting transcripts
// (cc) 2006 by Gwyneth Llewelyn. Some rights reserved.
// Feel free to copy and improve upon it, and, if you're nice, mention my name or
// send me a donation of L$1 :)
if (!isset($text))
{
// No data yet, let's draw those nice forms and all!
?>
<form action="colour-code.php" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2">Text to colourize:</td>
</tr>
<tr>
<td colspan="2">
<textarea name="text" rows="30" cols="100">Insert your transcript here.</textarea>
</td>
</tr>
<tr>
<td colspan="2">
Options:
</td>
</tr>
<tr>
<td>
Your Name: (replaces "You:")
</td>
<td>
<input type="text" name="You" size=32 value="Unknown Avatar" />
</td
</tr>
<tr>
<td>
Use bold for names?
</td>
<td>
<input type="checkbox" name="useBoldForNames" value="true" checked />
</td>
</tr>
<tr>
<td>
Use underline for names?
</td>
<td>
<input type="checkbox" name="useUnderlineForNames" value="true" />
</td>
</tr>
<tr>
<td>
Check SL forum post size limit?
</td>
<td>
<input type="checkbox" name="checkPostSizeLimit" value="true" checked />
</td>
</tr>
<tr>
<td>
Use vBulletin/phpBB/TikiWiki/HTML code?
</td>
<td>
<select name="phpBB">
<option selected value="1">vBulletin/phpBB</option>
<option value="0">HTML</option>
<option value="2">TikiWiki</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="submit" name="submit" value="Submit" />
</td>
</tr>
</table>
</form>
<?
}
else
{
// Parameters to format names
/*
$useBoldForNames = true;
$useUnderlineForNames = true;
$checkPostSizeLimit = true; // this is to allow cutting the output for SL forum posts
$phpBB = true; // set it to FALSE to use plain HTML
$You = "Unknown Avatar";
*/
// A short list of colours. Add more for more fun!
if ($phpBB) // vBulletin/phpBB seem to allow for many colours
{
$colours = array("Black", "Sienna", "DarkOliveGreen", "DarkGreen", "DarkSlateBlue",
"Navy", "Indigo", "DarkSlateGray", "DarkRed", "DarkOrange",
"Olive", "Green", "Teal", "Blue", "SlateGray", "DimGray", "Red",
"SandyBrown", "YellowGreen", "SeaGreen", "MediumTurquoise",
"RoyalBlue", "Purple", "Gray", "Magenta", "Orange", "Yellow",
"Lime", "Cyan", "DeepSkyBlue", "DarkOrchid", "Silver", "Pink",
"Wheat", "LemonChiffon", "PaleGreen", "PaleTurquoise",
"LightBlue", "Plum", "White",
"#00CC00", "#3300CC", "#660000", "#66CCCC", "#996600", "#CC3366",
"#330000", "#FFCC00", "#663300", "#666699", "#FF9966", "#990033",
"#3366FF", "#FFCCCC", "#99FF00", "#33CCCC", "#330066", "#99FFCC");
}
else // standard HTML defines less colours
{
$colours = array("Black", "Silver", "Gray", "Maroon", "Red", "Purple",
"Fuchsia", "Green", "Lime", "Olive", "Yellow", "Navy",
"Blue", "Teal", "Aqua",
"#00CC00", "#3300CC", "#660000", "#66CCCC", "#996600", "#CC3366",
"#330000", "#FFCC00", "#663300", "#666699", "#FF9966", "#990033",
"#3366FF", "#FFCCCC", "#99FF00", "#33CCCC", "#330066", "#99FFCC");
}
$coloursTotal = count($colours);
$currentColour = 0;
// Tags - changes depending on if we're using phpBB, HTML or TikiWiki
//print("Style is: $phpBB<br \>\n");
switch ($phpBB)
{
case "1":
define("COLOR", ""
;
define("ITALICS", ""
;
define("BOLD", ""
;
define("UNDERLINE", ""
;
define("COLOR_END", "");
define("ITALICS_END", "");
define("BOLD_END", "");
define("UNDERLINE_END", "");
define("HR", "");
define("LINE_END", "\n");
break;
case "2":
define("COLOR", "~~");
define("COLOR_END_BRACKET", ":");
define("ITALICS", "''");
define("BOLD", "__");
define("UNDERLINE", "===");
define("COLOR_END", "~~");
define("ITALICS_END", "''");
define("BOLD_END", "__");
define("UNDERLINE_END", "===");
define("HR", "---");
define("LINE_END", "\n");
break;
default:
define("COLOR", "<span style=\"color:");
define("COLOR_END_BRACKET", ";\">");
define("ITALICS", "<i>");
define("BOLD", "<b>");
define("UNDERLINE", "<u>");
define("COLOR_END", "</span>");
define("ITALICS_END", "</i>");
define("BOLD_END", "</b>");
define("UNDERLINE_END", "</u>");
define("HR", "<hr>");
define("LINE_END", "<br />\n");
break;
}
define("MAX_SIZE_PER_POST", 29000);
// array that links avatar name with one of the above colours
$avatarNamesColours = array("nobody" => "#000000");
$talkMode = true; // to handle /me'd text differently - italics, etc.
$byteCount = 0; // SL forum posts have a maximum of 30000 bytes
$chopBlockCount = 0;
// fix wrong values that come via form...
if ($useBoldForNames == "true") $useBoldForNames = true;
if ($useUnderlineForNames == "true") $useUnderlineForNames = true;
// start spewing out code...
if (!$phpBB) print("<div id=\"two-col\">\n");
if ($checkPostSizeLimit) // put blocks of chopped text inside textareas
print ("<form action=\"#\" method=\"post\">\n<textarea name=\"text-$chopBlockCount\" rows=\"10\" cols=\"100\" readonly>\n");
$lines = explode( "\n", $text);
foreach ($lines as $line)
{
$line = stripslashes(trim($line));
$line = ereg_replace("^You:", $You . ":", $line); // replace You by your avatar name
// split line into words separated by spaces to extract the avatar name easily
$words = explode(" ", $line);
// check if we're "talking" or /me'ing
$talkMode = (substr($words[1], -1) == ":");
// for convenience, get the first two words, aggregate them into an avatar
// name, and check if we have a ":" at the end or not
$avatarName = $words[0] . " " . trim($words[1], ":");
// see if we have a colour for it on our array avatarName/colour;
// if not, add to it
if (!isset($avatarNamesColours[$avatarName]))
{
// add a new colour to the array
$avatarNamesColours[$avatarName] = $colours[$currentColour];
// cycle to next available colour, or start from the beginning
$currentColour++; if ($currentColour > $coloursTotal) $currentColour = 0;
}
// now output a line
unset($words[0]); // these have the avatar name; discard them!
unset($words[1]);
$outputLine = COLOR . $avatarNamesColours[$avatarName] . COLOR_END_BRACKET
. ($talkMode ? "" : ITALICS)
. ($useBoldForNames & $talkMode ? BOLD : "")
. ($useUnderlineForNames & $talkMode ? UNDERLINE : "")
. $avatarName
. ($useUnderlineForNames & $talkMode ? UNDERLINE_END : "")
. ($useBoldForNames & $talkMode ? BOLD_END : "")
. ($talkMode ? ": ": " ")
. implode(" ", array_values($words))
. ($talkMode ? "" : ITALICS_END)
. COLOR_END . LINE_END;
// check if we have reached the limit for SL forum posts
if ($checkPostSizeLimit)
{
$byteCount += strlen($outputLine);
if ($byteCount >= MAX_SIZE_PER_POST)
{
print HR;
$chopBlockCount++;
// put blocks of chopped text inside textareas
print ("</textarea>\n<br />\n<textarea name=\"text-$chopBlockCount\" rows=\"10\" cols=\"100\" readonly>\n");
$byteCount = 0;
}
}
print $outputLine;
}
if ($checkPostSizeLimit) // put blocks of chopped text inside textareas
print ("</textarea>\n</form>\n");
if (!$phpBB) print("</div>\n");
}
?>
</body>
</html>
In the mean time, I just found out that Ulrika's website is up again! Ah well. Her script has a tiny bug dealing with the /me'd messages (which I handle differently), but it should actually work faster, since as I understand it, she does her programming in Perl, which should be much more efficient at dealing with string parsing.
EDIT 20060506: I had forgotten to post here the latest version, which adds TikiWiki colouring for those of you who need to post transcripts to Wikis.