File: fixmanual

package info (click to toggle)
kbtin 2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,856 kB
  • sloc: ansic: 18,627; perl: 179; sh: 88; makefile: 17
file content (48 lines) | stat: -rwxr-xr-x 937 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env perl
use warnings;

$caption=0;
$head=1;

while(<STDIN>)
{
    if($head && /^ / && !/\*\*\*/)
    {
        s:(\S+):<a href="#$1">$1</a>:g;
    }
    if(!/^~/)
    {
        print "$_";
        next;
    }
    if(/^~\*end\*/)
    {
        print "</tt></pre>";
        if($ARGV[0])
        {
            my $mtime = (stat($ARGV[0]))[9];
            # GMT is unfriendly, but we don't know the timezone of last change
            # vs the timezone of build machine.
            print "Last modified: ".gmtime($mtime)." GMT" if $mtime;
        }
        print "</body></html>\n";
        exit;
    }
    if(/^~~~/)
    {
        print "<hr>\n";
        $head=$caption=0;
        next;
    }
    if(/^~~H (.*)/)
    {
        print "<a name=\"$1\"></a><h5>$1</h5>\n";
        $caption=1;
        next;
    }
    if(/^~([^~].*)/)
    {
        print "<a name=\"$1\"></a>";
        print "<h5>#$1</h5>" unless $caption;
    }
}