File: unhtml

package info (click to toggle)
ispell-czech 20040229-5.2
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 3,588 kB
  • ctags: 5
  • sloc: perl: 703; makefile: 76; sh: 43
file content (100 lines) | stat: -rw-r--r-- 2,117 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/perl
 
  $where=0;
  $next=0;
  while (defined($what=&ReadNext)) {
    if ($where==0 && $prev!=1 && $prev!=3) {
      print $what;
    } else {
      print " ";
    }
    $prev=$where;
  }

sub ReadNext {
  if (!$line) {
    return undef if !($line=<>);
#print "READ: $line";
    $line=~s/\&nbsp\;/ /g;
  }
  if ($where==0) {
    if ($line=~s/^([^<]+)//) {
      $symbol=$1;
#print "\$symbol:\"$symbol\"";
      # OK
    } elsif ($line=~s/^(\<)//) {
      $symbol=$1;
#print "\$symbol:\"$symbol\"";
      $where=1;
#print " ->1 ";
    }
  } elsif ($where==1) {
    if ($line=~s/^(\!--)//) {
      $symbol=$1;
#print "Poznamka\n";
      $where=3;
      $ending='-->';
    } elsif ($line=~s/^([^>"]+)//) {
      $symbol=$1;
#print "\$symbol:\"$symbol\"";
      # OK
      if ($symbol=~/^style\b/i) {
#print "Kaskadovy styl\n";
        $next=3;
        $ending='<\\/style>';
      } elsif ($symbol=~/^script\b/i) {
#print "Skript\n";
        $next=3;
        $ending='<\\/script>';
      } elsif ($symbol=~s/^\!--//) {
#print "Poznamka\n";
        $where=3;
        $ending='-->';
      }
    } elsif ($line=~s/^(\")//) {
      $symbol=$1;
#print "\$symbol:\"$symbol\"";
      $where=2;
#print " ->2 ";
    } elsif ($line=~s/^(\>)//) {
      $symbol=$1;
#print "\$symbol:\"$symbol\"";
      $where=$next;
#print " ->$where ";
      $next=0;
    }
  } elsif ($where==2) {
    if ($line=~s/^([^"]+)//) {
      $symbol=$1;
#print "\$symbol:\"$symbol\"";
      # OK
    } elsif ($line=~s/^(\")//) {
      $symbol=$1;
#print "\$symbol:\"$symbol\"";
      $where=1;
#print " ->1 ";
    }
  } elsif ($where==3) {
#print "Radek: >>>$line<<<";
    if ($line=~s/^(.+?)($ending)/$2/i) {
#print "Bude $ending...";
      $symbol=$1;
    } elsif ($line=~s/^$ending//i) {
#print "Je $ending...";
      $where=0;
#print "Opou�t�m $ending ->$where ";
#print "\$prev: $prev\n";
      $symbol='';
    } else {
#print "Nen� $ending...";
      $symbol=$line;
      $line='';
    }
  }
#print "($where:$1)";
  $symbol=~s/\&quot\;/"/g;
  $symbol=~s/\&amp\;/&/g;
  $symbol=~s/\&lt\;/</g;
  $symbol=~s/\&gt\;/>/g;
  return $symbol;
}