File: patchhtml

package info (click to toggle)
c++-annotations 11.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 11,244 kB
  • sloc: cpp: 21,698; makefile: 1,505; ansic: 165; sh: 121; perl: 90
file content (61 lines) | stat: -rwxr-xr-x 1,126 bytes parent folder | download | duplicates (8)
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
#!/usr/bin/perl

$mark_in =  "<pre>";
$mark_out = "</pre>";

sub marked_section
{
    @marked = ("$_[0]$mark_in\n");

    while ($line = <>)
    {
        push @marked, $line;
        last if  $line =~ /$mark_out/;
    }
    
    print $marked[0];
    for ($from = 1; $marked[$from] =~ /^\s*$/; $from++)     # $from: at 1st to
    {}                                                      # print

    for ($to = $#marked - 1; $marked[$to] =~ /^\s*$/; $to--)# $to: last to pnt
    {}

    for ( ; $from <= $to; $from++)
    {
        print $marked[$from];
    }
    
    print $marked[$#marked];

    while ($line = <>)
    {
        last if  $line !~ /^\s*$/;
    }

    if ($line =~ /(.*)$mark_in\s*/)
    {
        marked_section($1);
    }
    else
    {
        print $line;
    }
}

while ($line = <>)
{
    # added $1 to pick up leading text. $2 now used to be $1
    if ($line =~ m#(.*)<title>\s*<center>(.*)</center>\s*</title>#)
    {
        print("$1<title>$2</title>\n");
        next;
    }
    elsif ($line =~ /(.*)$mark_in\s*/)
    {
        marked_section($1);
    }
    else
    {
        print $line;
    }
}