-
Notifications
You must be signed in to change notification settings - Fork 790
Expand file tree
/
Copy pathpextr
More file actions
executable file
·171 lines (155 loc) · 5.55 KB
/
pextr
File metadata and controls
executable file
·171 lines (155 loc) · 5.55 KB
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
#!/usr/local/bin/perl
# Extract entries from the CSS properties database
# The database has the following format:
# name;; values;; initial-value;; applies-to;;
# inherited;; percentages;; media;;
# Special characters:
# 1) Translate "*" into the words "all elements"
# 1.a) Translate "XX" into "not defined for shorthand properties"
# 2) "<name>" means the value is defined elsewhere. Translate to
# <span class="value-inst-name"><name></span>
# 3) "<'name'>" means the set of values is the same as for the
# property with the same name. Translate to
# <span class="propinst-name"><'name'></span>
#
# Ian Jacobs - ij@w3.org (Based on work by Arnaud Le Hors)
# $Id: pextr,v 1.18 1998-03-24 16:07:05 bbos Exp $
$PROGNAME = substr($0, rindex($0, "/") + 1);
if (!$ARGV[0]) {
print "Usage: $PROGNAME [-n] file [tgt_dir]\n";
exit 1;
}
if ($ARGV[0] eq "-n") {
$noindex = 1;
shift;
} else {
$noindex = 0;
}
# copy file in memory
if (!open(input, $ARGV[0])) {
print "$PROGNAME Error: Cannot open file: $ARGV[0]\n";
exit 1;
}
$buf = "";
while (<input>) {
$buf .= $_;
}
close(input);
$path = "";
if ($ARGV[1]) {
$path = "$ARGV[1]/";
}
# regexps
$sp = "[ \t\n]*"; # whitespace
$patt = "$sp(.*?)$sp";
$blockst = "[/][*]";
$blocket = "[*][/]";
sub format_property {
my $name = $_[0];
my $values = $_[1];
my $init = $_[2];
my $applies = $_[3];
my $inherited = $_[4];
my $percentages = $_[5];
my $media = $_[6];
#Do next three lines in src files to get headings right.
print output "<div class=\"propdef\">\n";
print output "<dl><dt>\n";
@names = split(/[, \t\n]+/, $name);
$comma = "";
foreach $n (@names) {
if ($noindex) {
print output "$comma<a name=\"propdef-$n\" class=\"propdef-title\"><strong>'$n'</strong></a>";
} else {
print output "$comma<span class=\"index-def\" title=\"'$n'\"><a name=\"propdef-$n\" class=\"propdef-title\"><strong>'$n'</strong></a></span>";
}
$comma = ", ";
}
print output "\n<dd>\n";
print output "<table class=\"propinfo\" cellspacing=0 cellpadding=0>\n";
# We use cellspacing/cellpadding until more browsers
# handle tables correctly.
&format_values($values);
&format_init($init);
&format_applies($applies);
&format_inherited($inherited);
&format_percentages($percentages);
&format_media($media);
print output "</table>\n";
print output "</dl>\n";
print output "</div>\n\n";
}
# Include an nbsp before TD since CSS not used to
# align tables yet.
sub format_values {
$values = $_[0];
$values =~ s/<([^>']*)>/<span class=\"value-inst-$1\"><$1><\/span>/g;
$values =~ s/<[']([^']*)[']>/<span class=\"propinst-$1\"><'$1'><\/span>/g;
$values =~ s/inherit/<span class=\"value-inst-inherit\">inherit<\/span>/g;
print output "<tr valign=baseline>";
print output "<td><em>Value:</em> ";
print output "<td>$values\n";
}
sub format_init {
#Note that in the case of properties, <> are removed in text.
$init = $_[0];
$init =~ s/XX/not defined for shorthand properties/g;
$init =~ s/<([^>']*)>/<span class=\"value-inst-$1\"><$1><\/span>/g;
$init =~ s/<[']([^']*)[']>/<span class=\"propinst-$1\">'$1'<\/span>/g;
print output "<tr valign=baseline>";
print output "<td><em>Initial:</em> ";
print output "<td>$init\n";
}
sub format_applies {
#Note that in the case of properties, <> are removed in text.
$applies = $_[0];
$applies =~ s/\*/all elements/g;
$applies =~ s/<([^>']*)>/<span class=\"value-inst-$1\"><$1><\/span>/g;
$applies =~ s/<[']([^']*)[']>/<span class=\"propinst-$1\">'$1'<\/span>/g;
print output "<tr valign=baseline>";
print output "<td><em>Applies to:</em> ";
print output "<td>$applies\n";
}
sub format_inherited {
print output "<tr valign=baseline>";
print output "<td><em>Inherited:</em> ";
print output "<td>$_[0]\n";
}
sub format_percentages {
#Note that in the case of properties, <> are removed in text.
$perc = $_[0];
$perc =~ s/<([^>']*)>/<span class=\"value-inst-$1\"><$1><\/span>/g;
$perc =~ s/<[']([^']*)[']>/<span class=\"propinst-$1\">'$1'<\/span>/g;
print output "<tr valign=baseline>";
print output "<td><em>Percentages:</em> ";
print output "<td>$perc\n";
}
sub format_media {
$fmedia = $_[0];
$fmedia =~ s/visual/<a href=\"media.html#visual-media-group\" class=\"noxref\">visual<\/a>/;
$fmedia =~ s/aural/<a href=\"media.html#aural-media-group\" class=\"noxref\">aural<\/a>/;
$fmedia =~ s/tactile/<a href=\"media.html#tactile-media-group\" class=\"noxref\">tactile<\/a>/;
$fmedia =~ s/continuous/<a href=\"media.html#continuous-media-group\" class=\"noxref\">continuous<\/a>/;
$fmedia =~ s/paged/<a href=\"media.html#paged-media-group\" class=\"noxref\">paged<\/a>/;
$fmedia =~ s/grid/<a href=\"media.html#grid-media-group\" class=\"noxref\">grid<\/a>/;
$fmedia =~ s/interactive/<a href=\"media.html#interactive-media-group\" class=\"noxref\">interactive<\/a>/;
$fmedia =~ s/static/<a href=\"media.html#static-media-group\" class=\"noxref\">static<\/a>/;
$fmedia =~ s/all/<a href=\"media.html#all-media-group\" class=\"noxref\">all<\/a>/;
print output "<tr valign=baseline>";
print output "<td><em>Media:</em> ";
print output "<td>$fmedia\n";
}
# extract every possible block
$_ = $buf;
while (/$blockst$patt;;$patt;;$patt;;$patt;;$patt;;$patt;;$patt$blocket/s) {
# Set parameters first (before any modifications)
$placeholder = $';
my @names = split(/[, \t\n]+/, $1);
my $name = $names[0];
$output = "$path$name.srb";
print "\textracting $output\n";
open(output, "> $output");
&format_property($1, $2, $3, $4, $5, $6, $7);
close(output);
$_ = $placeholder;
}