Skip to content

Instantly share code, notes, and snippets.

@DivinityArcane
Created November 2, 2012 05:25
Show Gist options
  • Save DivinityArcane/3998896 to your computer and use it in GitHub Desktop.
Save DivinityArcane/3998896 to your computer and use it in GitHub Desktop.
dAmnPearl's tablump parser
sub tablumps {
my $string = $_[0];
# Dev links
$string =~ s/&dev\t([^\t])\t([^\t]+)\t/:dev$2:/g;
# Icons
$string =~ s/&avatar\t([^\t]+)\t([^\t]+)\t/:icon$1:/g;
# Abbr/Acronym
$string =~ s/&(abbr|acro)\t([^\t]+)\t/<$1 title="$2">/g;
# Links
$string =~ s/&a\t([^\t]+)\t([^\t]*)\t/<a href="$1">/g;
$string =~ s/&link\t([^\t]+)\t([^\t]+)\t([^\t]+)\t/<a href="$1">$2<\/a>/g;
$string =~ s/&link\t([^\t]+)\t([^\t]+)\t/$1/g;
# Images and IFrames
$string =~ s/&(img|iframe)\t([^\t]+)\t([^\t]*)\t([^\t]+)\t/<$1 src="$2" \/>/g;
# Don't think any other simple ones are supported?
$string =~ s/&(|\/)(a|b|i|u|s|sup|sub|code|bcode|abbr|acro)\t/<$1$2>/g;
# Breaks!
$string =~ s/&br\t/<br\/>/g;
# Thumbs
$string =~ s/&thumb\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t/:thumb$1:/g;
# Emotes
$string =~ s/&emote\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t/$1/g;
return $string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment