mIRC Home    About    Download    Register    News    Help

Print Thread
#151915 23/06/06 08:13 AM
Joined: Nov 2003
Posts: 157
RuFy Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Nov 2003
Posts: 157
Hi, I have downloaded this code from a site, but there is some problem with color conversion from mIRC to html.
If I type: [colorcode]4This is a test[colorcode] it work, but if I type: [colorcode]4,1This is a test[colorcode] it won't work, because it return:
<font face="tahoma" size="2"><span style="color:#FF0000;background-color: #FFFFFF"> 1This is a test<span style="color:#000000;background-color: #FFFFFF"></span></span><br>

I think that there is a problem in some regex or regsub strings, but I can't solve it because I don't understand well the Regular Expression.
This is the code:
Code:
Alias m2h {
    var %x $1- , %f = $iif($regex($prop,/([a-z]+)/i),$regml(1),tahoma) , %s = $iif($regex($prop,/(\d+)/i),$regml(1),2)
    ;codes ascii : b &gt; 2 , k &gt; 3 , o &gt; 15 , r &gt; 22 , u &gt; 31
    ;replace bold
    var %y = $regsub(%x,/\002(.*?)(?:\002|$)/g,&lt;b&gt;\1&lt;/b&gt;,%x)
    ;replace underline (\031 ne fonctionne pas dans la regex)
    var %y = $regsub(%x,/ $chr(31) (.*?)(?: $chr(31) |$)/gx,&lt;u&gt;\1&lt;/u&gt;,%x) , %x = $remove(%x,&lt;b&gt;&lt;/b&gt;,&lt;u&gt;&lt;/u&gt;)
    ;permet que les ctrl + O éliminent le gras et le souligné , + Reverse
    var %y = $regsub(%x,/(&lt;b&gt;.*) $chr(15) (.*)&lt;/b&gt;/gx,\1&lt;/b&gt; $+ $chr(15) $+ \2&lt;/b&gt;,%x) , %x = $replace(%x,$chr(15),$+($chr(3),01,$chr(44),00),$chr(22),$+($chr(3),00,$chr(44),01))
    ;replace ctrl + K
    while $regex(%x,^(.*)\003(\d{0,2},?\d{0,2})(.*?)(?:\003|$)(.*)) {
    tokenize 44 $regml(2)
    %x = $regml(1) $+ &lt;span style="color: $+ $col($iif($1 isnum 0-15,$1,1)) $+ ;background-color: $+ $col($iif($2 isnum 0-15,$2,0)) $+ "&gt; $+ $regml(3) $+ &lt;/span&gt; $+ $regml(4)
    }
    return $+(&lt;font face=",%f," size=",%s,"&gt;,%x,&lt;p&gt;)
}
Alias -l col { tokenize 44 $rgb($color($1)) | return $+($chr(35),$base($1,10,16,2),$base($2,10,16,2),$base($3,10,16,2)) }

Joined: Jul 2004
Posts: 31
H
Ameglian cow
Offline
Ameglian cow
H
Joined: Jul 2004
Posts: 31
//var %x = $chr(3) $+ 4,6this is a test | echo -a $m2h(%x)

works fine here. Your problem is probably that you do $m2h([colorcode]4,6this is a test) because that will put [colorcode4 in $1 and 6this in $2 etc. the , will be lost


Link Copied to Clipboard