(.*?)<\/pre>/gs);
$prei=0;
while ( $str =~ s/(.*?)<\/pre>/__pre${prei}__/s) {
$prei++;
}}
# deal with annoying .\italics.\
almlital($str);
# link: note convertor is at the end here
almllink($str);
# deal with ()s parens
almlparen($str);
#deal with old shortform of ...
$str =~ s///g;
#deal with \>-)
$str =~ s/\\</g;
$str =~ s/\\>/>/g;
###
#####deal with "quotes": set up array of " and positions
###
#$str =~ s/\"(\w*)\"/~${1}~/g;
$str =~ s/\\\"/"/g;
## make quotes list
@quots=();
$n = -1;
while (1) {
$_=index($str, "\"",$n);
if ($_ == -1) {
last;}
push(@quots, $_);
$n=1+$_;
}
## make tags list
@tags=();
$n = -1;
while (1) {
$lt = index($str, "<", $n);
$gt = index($str, ">", $n);
#print "lt gt: $lt $gt\n";
if (($lt == -1) && ($gt == -1)) {last;}
push(@tags, $lt, $gt );
#if we ever expect this to be needed...
##if ($lt < $gt) { $n = $gt +1 ; } else {$n = $lt +1 ;}
$n = $gt + 1;
}
## purge quotes inside tags
$t = 0;
$q = 0;
@tagclose=();
while ($t <= $#tags) { #not foreached because we need to increm by 2
#set up @tagclose for <>
if ($tags[$t] +1 == $tags[$t+1]) {
$prevtag=substr($str, $tags[$t-2], 1+$tags[$t-1]-$tags[$t-2]);
#print "phoobe: $t, $tags[$t-1], $prevtag \n
";
$prevtag =~ s/<(.*?)(?:( .*?)>|(?)>)/<\/${1}>/g;
push(@tagclose, $prevtag);
$t+=2;
next;
}
foreach $q (0..$#quots) {
#while ($q <= $#quots) {
if (($quots[$q] > $tags[$t]) && ($quots[$q] < $tags[$t+1])){
#delete $quots[$q];
$quots[$q]=-1;
}
}
$t+=2;
}
## rebuild the string
$i=0;
$qflag = 0;
$offsets=0;
foreach $i (0..$#quots) {
if ($quots[$i] == -1) {
next;
}
if ($qflag == 0) {
substr($str, $quots[$i]+$offsets, 1) = "\"";
$offsets+=4;
$qflag = 1;
}
else {
substr($str, $quots[$i]+$offsets, 1) = "\"";
$offsets+=5;
$qflag = 0;
}
}
# take care of <>'s
$n = -1;
$t=0;
while (1) {
$_=index($str, "<>",$n);
if ($_ == -1) {
last;}
substr($str, $_, 2) = $tagclose[$t];
$t++;
$n=1+$_;
}
#
#####FINISH QUOTES STUFF
#
# to take care of used in <>
$str =~ s/<\/link>/<\/a>/g;
#deal with \n\n->s parags, \n->
breaks
$str =~ s/\n\n/
/g;
$str =~ s/\n([^ ])/\n
$1/g;
# Remove
and
from
things
while (($breaker) = $str =~ m/.*?(
|).*?<\/pre>/gs) {
$str =~ s/
(.*?)${breaker}(.*?)<\/pre>/${1}${2}<\/pre>/gs;
}
# NOT USED
#another method of removing all tags from PREs...
if (0) {
#final PRE
foreach $prei (0..$#precontents) {
#print "prei: $prei->$stf[$prei]\n";
$prestr="__pre${prei}__";
$str =~ s/$prestr/@precontents[$prei]<\/pre>/gs;
}}
# i r teh jeo!!!
}