File: makehtml.pl

package info (click to toggle)
gob2 2.0.17-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 1,564 kB
  • ctags: 1,406
  • sloc: ansic: 5,133; yacc: 2,023; sh: 1,156; lex: 623; perl: 431; makefile: 69
file content (96 lines) | stat: -rwxr-xr-x 2,164 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
#!/usr/bin/perl
$printbr = 1;
$printtable = 0;
while (<>) {
	s/\\&//g;
	s/&/&amp;/g;
	s/\</&lt;/g;
	s/\>/&gt;/g;
	s/\\'/'/g;
	s/\\-/-/g;
	if ($printtable == 1) {
		$printtable = 2;
	} elsif ($printtable == 2) {
		$printtable = 3;
		print "</TD><TD ALIGN=\"left\">";
	}

	#hack, we're inside .nf so highlight comments and
	# other such stuff
	if ($printbr == 0) {
		s/\/\*/<FONT COLOR="#5555ff">\/\*/g;
		s/\*\//\*\/<\/FONT>/g;
	}
	
	if (/^\.\\"/) {
		# comment ignore
	} elsif (/^\.TH .*\"([^"]*)\"/) {
		# must be at the front
		print "<HTML><HEAD><TITLE>$1 Manual page</TITLE></HEAD>\n";
		print "<BODY BGCOLOR=\"#ffffff\">\n";
		print "<H1>$1 Manual page</H1>\n";
	} elsif (/^\.SH (.*)$/) {
		if ($printtable == 3) {
			$printtable = 0;
			print "</TD></TR></TABLE>\n";
		}
		print "<H3>$1</H3>\n";
	} elsif (/^\.PP/) {
		if ($printtable == 3) {
			$printtable = 0;
			print "</TD></TR></TABLE>\n";
		}
		print "<P>\n";
	} elsif (/^\.IP/) {
		if ($printtable == 3) {
			$printtable = 0;
			print "</TD></TR></TABLE>\n";
		}
		print "<P>\n";
	} elsif (/^\.B "(.*)"$/) {
		print "<B>$1</B>\n";
	} elsif (/^\.B (.*)$/) {
		print "<B>$1</B>\n";
	} elsif (/^\.I "(.*)"$/) {
		print "<I>$1</I>\n";
	} elsif (/^\.I (.*)$/) {
		print "<I>$1</I>\n";
	} elsif (/^\.nf/) {
		if ($printtable == 3) {
			$printtable = 0;
			print "</TD></TR></TABLE>\n";
		}
		print "<TABLE WIDTH=100%><TR><TD BGCOLOR=\"#dddddd\"><PRE>\n";
		$printbr = 0;
	} elsif (/^\.fi/) {
		print "</PRE>\n";
		print "</TD></TR></TABLE>\n";
		$printbr = 1;
	} elsif (/^[ 	]*$/) {
		if ($printtable == 3) {
			$printtable = 0;
			print "</TD></TR></TABLE>\n";
		}
		if ($printbr) {
			print "<BR>\n";
		} else {
			print "\n";
		}
	} elsif (/^\.TP/) {
		if ($printtable == 3) {
			$printtable = 1;
			print "</TD></TR><TR>\n<TD ALIGN=\"left\">";
		} else {
			$printtable = 1;
			print "<TABLE BORDER><TR>\n<TD ALIGN=\"left\">";
		}
	} else {
		s/\\fB([^\\]*)\\fR/<B>\1<\/B>/gm;
		s/\\fI([^\\]*)\\fR/<I>\1<\/I>/gm;
		s/&lt;([a-zA-Z0-9.]+\@[a-zA-Z0-9.]+)&gt;/&lt;<a href=\"mailto:\1\">\1<\/a>&gt;/g;
		s/(http:\/\/[a-zA-Z0-9.\/~]+\.html)/<a href=\"\1\">\1<\/a>/g;
		print;
	}
}

print "</BODY></HTML>\n";