Advertisement
OrenWatson

ttml2html.pl (not all things supported)

Dec 6th, 2014
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.53 KB | None | 0 0
  1. print <<'EOM';
  2. <style>
  3. hr {position:absolute;border: inset 1px;left:0px;width:800px;}
  4. span {position:absolute; font-size: 16px; font-family:monospace;
  5. transform-origin:0% 0%;white-space: pre-wrap;}
  6. .bold {font-weight:bold;}
  7. .small {transform:scale(0.75,0.75)translate(0px,4px);}
  8. .italic {font-style:italic;}
  9. .grey {color:grey;}
  10. .blue {color:blue;}
  11. .red {color:red;}
  12. .green {color:green;}
  13. .royal {color:purple;}
  14. .highlighted {background-color:gold;}
  15. .underlined {border-bottom: 1px solid black;}
  16. .strikethru {text-decoration:line-through;}
  17. .dblht.dblwid {transform:scale(2,2);}
  18. .dblwid:not(.dblht) {transform:scale(2,1);}
  19. .dblht:not(.dblwid) {transform:scale(1,2);}
  20. </style>
  21. <p><span>
  22. EOM
  23. $x = 0;
  24. $y = 0;
  25. $w = 10;
  26. $h = 16;
  27. $size = "";
  28. $decor = '';
  29. $weight = '';
  30. $color = "";
  31. $style = '';
  32. $lastclass = 'kklklkslkalkjsdlad';
  33. while(1){
  34.     $c=getc();
  35.     if(!defined $c){last;}
  36.     $n = ord($c);
  37.     if($c eq '^'){
  38.         $c=getc();
  39.         $n=ord($c)-ord('@');
  40.     }
  41.     again:
  42.     if($c eq'>'){$cc="&#".$n.";";
  43.     }elsif($c eq'<'){$cc="&#".$n.";";
  44.     }elsif($c eq'&'){$cc="&#".$n.";";
  45.     }else{$cc=$c;}
  46.     if($n>=32){
  47.         $class = $size.$decor.$weight.$color.$style;
  48.         if($lastclass ne $class || $y != $lasty || $lastx != $x){
  49.             print "</span><span class='".$class."' style='height:16px;"#width:10px;
  50.             ."left:".$x."px;top:".$y."px;'>".$cc;
  51.         }else{
  52.             print $cc;
  53.         }
  54.         $x += $w;
  55.         $lastclass = $class;
  56.         $lasty = $y;
  57.         $lastx = $x;
  58.     }elsif($n==1){
  59.         $weight = 'bold ';
  60.     }elsif($n==2){
  61.         $size = '';
  62.         $weight = '';
  63.         $decor = '';
  64.         $style = '';
  65.         $color = '';
  66.         $w=10;
  67.         $h=16;
  68.     }elsif($n==3){
  69.         $size = 'small ';
  70.         $w = 7.5;
  71.         $h = 12;
  72.     }elsif($n==5){
  73.         $style = 'italic ';
  74.     }elsif($n==6){
  75.         $decor = 'underlined ';
  76.     }elsif($n==7){
  77.         $decor = 'highlighted ';
  78.     }elsif($n==8){
  79.         $x -= $w;
  80.     }elsif($n==9){
  81.         $x += $w/2;
  82.     }elsif($n==10){
  83.         $y += $h;
  84.     }elsif($n==11){
  85.         $y += $h/2;
  86.     }elsif($n==12){
  87.         print "<hr style='top:".($y+$h)."px'/>\n";
  88.         $y += $h*2;
  89.     }elsif($n==13){
  90.         $x = 0;
  91.     }elsif($n==16){
  92.         $color = 'grey ';
  93.     }elsif($n==17){
  94.         $color = 'green ;'
  95.     }elsif($n==18){
  96.         $color = 'red ';
  97.     }elsif($n==19){
  98.         $color = 'blue ';
  99.     }elsif($n==20){
  100.         $color = 'royal ';
  101.     }elsif($n==21){
  102.         $decor = 'strikethru ';
  103.     }elsif($n==22){
  104.         $size .= 'dblwid ';
  105.         $w = 20;
  106.     }elsif($n==23){
  107.         $size .= 'dblht ';
  108.         $h = 32;
  109.     }elsif($n==24){
  110.         $style = '';
  111.         $decor = '';
  112.         $weight = '';
  113.     }elsif($n==25){
  114.         $color = '';
  115.     }elsif($n==28){
  116.         getc();
  117.     }elsif($n==30){
  118.         $n = ord('^');
  119.         goto again;
  120.     }
  121.  
  122. }
  123. print '</span></p>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement