forked from w3c/csswg-drafts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkpropidx
executable file
·198 lines (175 loc) · 5.14 KB
/
mkpropidx
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#!/usr/local/bin/perl
# Index of property names.
# Arnaud Le Hors lehors@w3.org/Ian Jacobs ij@w3.org
# $Id: mkpropidx,v 2.16 2006-10-09 18:55:52 ihickson Exp $
use English;
$realpath = ();
while ($ARGV[0] =~ /^-/) {
if ($ARGV[0] eq "-r" && $ARGV[1]) {
shift;
$realpath = shift;
} else {
print "Usage: $PROGNAME [-r realpath] indexfile dbase\n";
exit 1;
}
}
$PROGNAME = substr($0, rindex($0, "/") + 1);
if (!$ARGV[1]) {
print "Usage: $PROGNAME [-r realpath] indexfile dbase\n";
exit 1;
} else {
$indexf = $ARGV[0];
$dbasef = $ARGV[1];
}
### main
# compute path relative to index file
$root = "";
@elems = split("/", $indexf);
pop @elems; # get rid of the file itself
foreach (@elems) {
$root .= "../";
}
# copy file in memory
sub readdb {
if (!open(DBASE, $_[0])) {
die "$PROGNAME Error: Cannot open file: $_[0]\n";
}
$INPUT_RECORD_SEPARATOR="/*";
$buf = "";
@indexes = ();
while ($buf = <DBASE>) {
$INPUT_RECORD_SEPARATOR="*/";
unless (eof(DBASE)) {
$entry=<DBASE>;
$INPUT_RECORD_SEPARATOR="/*";
if ($entry =~ /((.*?);;.*)\*\//sio) {
$data = $1;
$key = $2;
# Newlines and tabs-> space
$data =~ s/[\n\t]+/ /gs;
push(@indexes, ($data));
} else {
warn "Bad syntax: $entry\n";
}
}
}
close(DBASE);
}
sub cleanup {
# Put in right HTML markup
$arg = $_[0];
$arg =~ s/^[ \t\n]+//gs;
$arg =~ s/[ \t\n]+$//gs;
$arg =~ s/[&]/\&\;/gs;
$arg =~ s/[<]/\<\;/gs;
$arg =~ s/[>]/\>\;/gs;
$arg =~ s/\{([^\}]*)\}([^{]*)\{\}/<a href=\"$1\">$2<\/a>/g;
return "$arg";
}
# Property database entries between "/*" and "*/"
# Adding " xref" to the class allows addlinks to allow
# html2ps to insert page numbers
sub format_name {
print OUTPUT "<td>";
foreach $name (split(' ', $_[0])) {
$name = cleanup($name);
print OUTPUT "<span class=\"propinst-" . $name . " xref\">'" . $name . "'<\/span>\n";
}
}
sub format_val {
# Replace <n> by link to value def of n
# Replace <'m'> by link to property 'm'
$value = $_[0];
$value =~ s/^[ \t\n]+//gs;
$value =~ s/[ \t\n]+$//gs;
$value =~ s/\<([^']+?)\>/<span class=\"value-inst-\1\">\<\;\1\>\;<\/span>/sgi;
$value =~ s/\<\'(.+?)\'\>/<span class=\"propinst-\1\">\'\1\'<\/span>/sgi;
$value =~ s/inherit/<span class=\"value-inst-inherit\">inherit<\/span>/g;
print OUTPUT "<td>$value\n";
}
sub format_init {
print OUTPUT "<td>" . cleanup($_[0]) . "\n";
}
sub format_app {
# Replace * by a space (since most props take *).
$applies = cleanup($_[0]);
$applies =~ s/[*]/ /;
print OUTPUT "<td>$applies\n";
}
sub format_inh {
# If not inherited, don't print anything.
$inherited = cleanup($_[0]);
# $inherited =~ s/^no$/ /;
print OUTPUT "<td>$inherited\n";
}
sub format_perc {
# Replace N/A by a space (since most N/A).
$percentages = $_[0];
$percentages =~ s/^[ \t\n]+//gs;
$percentages =~ s/[ \t\n]+$//gs;
$percentages =~ s/N\/A/ /;
$percentages =~ s/\<\'(.+?)\'\>/<span class=\"propinst-\1\">\'\1\'<\/span>/sgi;
print OUTPUT "<td>$percentages\n";
}
sub format_media {
# If just visual, replace by space.
$fmedia = cleanup($_[0]);
$fmedia =~ s/visual/<a href=\"media.html#visual-media-group\">visual<\/a>/;
$fmedia =~ s/aural/<a href=\"aural.html#aural-media-group\">aural<\/a>/;
$fmedia =~ s/tactile/<a href=\"media.html#tactile-media-group\">tactile<\/a>/;
$fmedia =~ s/continuous/<a href=\"media.html#continuous-media-group\">continuous<\/a>/;
$fmedia =~ s/paged/<a href=\"media.html#paged-media-group\">paged<\/a>/;
$fmedia =~ s/grid/<a href=\"media.html#grid-media-group\">grid<\/a>/;
$fmedia =~ s/interactive/<a href=\"media.html#interactive-media-group\">interactive<\/a>/;
$fmedia =~ s/static/<a href=\"media.html#static-media-group\">static<\/a>/;
$fmedia =~ s/all/<a href=\"media.html#all-media-group\">all<\/a>/;
print OUTPUT "<td>$fmedia\n";
}
#sub format_compval {
# $compval = cleanup($_[0]);
# print OUTPUT "<td>$compval\n";
#}
sub table_head {
print OUTPUT "<table border=1>\n";
print OUTPUT "<thead>";
print OUTPUT "<tr align=center>";
print OUTPUT "<th>Name";
print OUTPUT "<th>Values";
print OUTPUT "<th>Initial value";
print OUTPUT "<th>Applies to<br>(Default: all)";
# print OUTPUT "<th>Inherited? <BR> (Default: no)";
print OUTPUT "<th>Inherited?";
print OUTPUT "<th>Percentages<br>(Default: N/A)";
print OUTPUT "<th>Media groups";
#print OUTPUT "<th>Computed value";
print OUTPUT "</thead>";
print OUTPUT "\n";
}
sub table_body {
foreach $x (sort @indexes) {
($name, $val, $init, $app, $inh, $perc, $media, $compval) = split(/;;/, $x);
if ($name !~ /\s*property-name\s*/) { # Skip the example
print OUTPUT "<tr>";
format_name($name);
format_val($val);
format_init($init);
format_app($app);
format_inh($inh);
format_perc($perc);
format_media($media);
#format_compval($compval);
print OUTPUT "\n";
}
}
}
sub table_foot {
print OUTPUT "</table>\n";
}
# main
readdb($dbasef);
open(OUTPUT, "> $indexf");
table_head();
table_body();
table_foot();
close(OUTPUT);
close(DBASE);