xhtml v1.2 — File Browser

xhtmlv1.2v1.2 / xhtmlv1.2v1.2 / xhtml.mrc

xhtml.mrc — 2.21 KB — Download this file

/*

Created by: Rand (DALnet)
Script:     xhtml v1.2

*/

alias html {
  var %text = $replace($1-,<,&lt;,>,&gt;)
  var %text = $regsubex(%text,/(.*?(?:||$))/g,<b>\t</b>)
  var %text = $regsubex(%text,/(.*?(?:||$))/g,<u>\t</u>)
  var %text = $regsubex(%text,/([0-9][^]*)/g,<font>\t</font>)
  var %text = $regsubex(%text,/<font>([0-9]{1,2}(?:,[0-9]{1,2}|))/g,<font color=" $+ $hexcolor($gettok(\t,1,44)) $+ " $iif($gettok(\t,2,44),style="background-color: $hexcolor($v1) $+ ;") $+ >)
  var %text = $regsubex(%text,/(.*?(?:||$))/g,$revrep(\t))
  var %text = $regsubex($strip(%text),/<([\S|^>]+)(?:\s[^>]+|)><\/\1>/g,)
  return $strip(%text)
}

alias revrep {
  var %v1 = $+(<xyz>,$1-,</xyz>)
  var %rs = $regsub(%v1,/<font [^>]+>(.*?)<\/font>/g,\1,%v1)
  var %rs = $regsub(%v1,/^(.*?)<\/font>/,</font>\1,%v1)
  var %rs = $regsub(%v1,/(<font [^>]+>)(.*?)$/,\2\1,%v1)
  var %v1 = $regsubex(%v1,/<xyz>(.*?)<\/xyz>/,<font color=" $+ $hexcolor($color(background)) $+ " style="background-color: $hexcolor($color(own)) $+ ;">\1</font>)
  return %v1
}


alias xhtml {
  set %lcount 0
  set %fcount $line($active,0)
  .fopen -o xhtml $iif($1,$qt($1-),$qt($+($scriptdir,$remove($active,$chr(35),\,/,:,*,?,",<,>,$chr(124)),.html)))
  var %ticks = $ticks
  .fwrite -n xhtml <html><body bgcolor= $+ $hexcolor($color(background)) $+ > <font face=" $+ $window($active).font $+ " style="size: $window($active).fontsize $+ px;" color= $+ $hexcolor($color(own)) $+ >
  filter -gwk $active htmlfilter /.*/
  .fwrite -n xhtml </font></body></html>
  .fclose xhtml
  ;editbox $active
  echo -stg xhtml: Completed in $calc(( $ticks - %ticks ) / 1000) $+ s ( $+ %lcount lines)
  unset %lcount %fcount %f
}
alias -l htmlfilter { 
  inc %lcount | dec %fcount
  ; uncomment the editbox line to show the remaining lines in your editbox
  ; however, doing so will increase the processing time (by quite a bit)..
  ;editbox -a Lines remaining: %fcount
  .fwrite -n xhtml <font color= $+ $hexcolor($line($active,%lcount).color) $+ > $html($1-) $+ </font><br>
}
alias ehtml { 
  echo -ag $html($1-) 
}
alias hexcolor { 
  tokenize 44 $rgb($color($1))
  return $+($chr(35),$base($1,10,16,2),$base($2,10,16,2),$base($3,10,16,2))
}