aboutsummaryrefslogtreecommitdiff
path: root/postproc.awk
diff options
context:
space:
mode:
Diffstat (limited to 'postproc.awk')
-rw-r--r--postproc.awk81
1 files changed, 81 insertions, 0 deletions
diff --git a/postproc.awk b/postproc.awk
new file mode 100644
index 0000000..c0c347a
--- /dev/null
+++ b/postproc.awk
@@ -0,0 +1,81 @@
1BEGIN {
2 if (!filename)
3 filename = "a";
4}
5function out(text) {
6 print text >> (filename "." state)
7}
8function downh(num) {
9 num=substr($0, 3, 1)
10 sub(/<h[0-9]>/,("<h" (num+1) ">"))
11 sub(/<\/h[0-9]>/,("</h" (num+1) ">"))
12}
13state == 0 && /<body>/ { state = 1; next }
14state == 0 { next }
15
16state == 1 && /<h1>/ {
17 gsub(/\\-/,"-")
18 downh()
19 out($0);
20 next
21}
22state == 1 && /<hr>/ {
23 out("<hr>");
24 state = 2;
25 next
26}
27state == 1 { next }
28
29state == 2 && /<h2>Index<\/h2>/ {
30 state = 3;
31 out($0);
32 next
33}
34# man2html is unable to handle commands like:
35# .IP \n[step].
36# Instead of evaluating \n[step], it strips "\n[" and leaves the rest
37# untouched. The klugde below is based on the assumption that we always
38# use step as the name of the variable.
39state == 2 && /<dl/ { counter=1 }
40state == 2 && /<dt>step\]\./ {
41 sub(/<dt>step\]\./,("<dt>" counter "."))
42 ++counter
43}
44
45state == 2 && /<h2>COMMANDS<\/h2>/ { command_links=1; out($0); next }
46state == 2 && /<h2>/ { command_links=0 }
47state == 2 && command_links == 1 && /^<b>.*<\/b>[,.]$/ {
48 punct=substr($0,length($0))
49 sub(/<b>/,"")
50 sub(/<\/b>[,.]/,"")
51 out("<b><a href=\"eclat-" $0 ".html\">" $0 "</a></b>" punct)
52 if (punct == ".")
53 command_links=0
54 next
55}
56
57state == 3 && /<hr>/ {
58 out($0);
59 state = 4;
60 next
61}
62
63state == 4 {
64 out("<p>This document was created by <a href=\"http://primates.ximian.com/~flucifredi/man/\">man2html</a> and postprocessed by postproc.awk.</p>")
65 out("<p>" strftime("%c", systime()) "</p>")
66 exit
67}
68
69/<h[0-9]>/ { downh() }
70
71{
72 s=gensub(/HREF="\.\.\/man[1-8n]\/(eclat[a-z.-]*)\.[1-8n]\.html/,
73 "href=\"\\1.html", "g")
74 s=gensub(/HREF="\.\.\/man[1-8n]\/(forlan[a-z.-]*)\.[1-8n]\.html/,
75 "href=\"\\1.html", "g",s)
76 s=gensub(/HREF="\.\.\/man([1-8n])\/(.+)\.[1-8n]\.html/,
77 "href=\"http://www.manpagez.com/man/\\1/\\2/","g",s)
78 out(s)
79}
80
81 \ No newline at end of file

Return to:

Send suggestions and report system problems to the System administrator.