DAmn/Tablumps

From Botdom Documentation
Jump to: navigation, search

Tablumps is an unofficial name for the encoding dAmn uses to send html tags and other entities in the body of certain packets. They are not very readable by humans, so clients need to parse them into more usable text.

Format

Tablumps have a slightly irregular format; on the surface they seem difficult to parse. However, they can be generalized into a relatively simple format.

Generalized Format

All tablumps follow some form of this format (\t represents a tab character):

&name\tsomearg\tanotherarg\t

Where name specifies which the tablump is and the args are zero or more arguments that accompany it. Unfortunately, the format does not specify where the last argument ends for most tablumps, so a client has to know beforehand how many arguments each tablump has (the exception being link tablumps detailed further below).

Parsing

Original Method

The original method used by the official client and several others is to apply a regular expression substitution to the message body for each type of tablump. This is relatively simple, but ineffective and potentially fragile.

Examples include:

replace(/&b\t/g, '<b>')
replace(/&abbr\t([^\t]*)\t/g, '<abbr title="$1">')

You can see all the replacements used by the official client in chat.js in the function dAmnChanChat.prototype.FormatMsg.

Tokenizing Method

Another way to handle tablumps would be to search through the message body for each occurrence of & read until the end of the tablump. In most cases, this is the index of the first tab character. However some tablumps have additional arguments. Below is a list of all tablumps, what they represent, and their arguments.

Example Parsers

To see other examples of tablumps parsers, take a look at the Tablumps Parsers page.

Zero Arguments

b:		<strong>
i:		<em>
u:		<u>
sub:		<sub>
sup:		<sup>
s:		<del>
p:		<p>
br:		<br />
code:		<code>
bcode:		<pre><code>
li:		<li>
ul:		<ul>
ol:		<ol>
/b:		</strong>
/i:		</em>
/u:		</u>
/sub:		</sub>
/sup:		</sup>
/s:		</del>
/p:		</p>
/code:		</code>
/bcode:		</code></pre>
/li:		</li>
/ul:		</ul>
/ol:		</ol>
/abbr:		</abbr>
/acro:		</acronym>
/a:		</a>
/iframe:	</iframe>
/embed:		</embed>

One Argument

abbr:		<abbr title="$1">
acro:		<acronym title="$1">

Two Arguments

a:		<a href="$1" title="$2">
dev:		:dev$2: - $1<a href="$2.deviantart.com">$2</a>
avatar:		:icon$1: - <a href="$1.deviantart.com">Image determined by $2

Three Arguments

img:		<img src="$1" height="$2" width="$3" />
iframe:		<iframe src="$1" height="$2" width="$3">
embed:		<embed src="$1" height="$2" width="$3">

Five Arguments

emote:		$1 - <img alt="$1" width="$2" height="$3" title="$4" src="http://e.deviantart.com/emoticons/$5" />

Six Arguments

thumb:		:thumb$1: - image tag determined by arguments

Variable Arguments

link:		detailed below

link is a special case of tablump. It can have either two or three arguments, but the last is always a single &. If there's only one argument before the &, it translates into <a href="$1" title="$1">[link]</a> otherwise it becomes <a href="$1" title="$1">$2</a>