-
Notifications
You must be signed in to change notification settings - Fork 790
Expand file tree
/
Copy pathpextr
More file actions
executable file
·139 lines (124 loc) · 4.69 KB
/
pextr
File metadata and controls
executable file
·139 lines (124 loc) · 4.69 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
#!/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.6 1997-12-16 20:51:56 ijacobs Exp $
$PROGNAME = substr($0, rindex($0, "/") + 1);
if (!$ARGV[0]) {
print "Usage: $PROGNAME file [tgt_dir]\n";
exit 1;
}
# 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 {
$name = $_[0];
$values = $_[1];
$init = $_[2];
$applies = $_[3];
$inherited = $_[4];
$percentages = $_[5];
$media = $_[6];
#Do next three lines in src files to get headings right.
print output "<DIV class=\"propdef\">\n";
print output "<P><a name=\"propdef-$name\" class=\"propdef-title\"><strong>'$name'</strong></a></P>\n";
print output "<TABLE class=\"propinfo\">\n";
&format_name($name);
&format_values($values);
&format_init($init);
&format_applies($applies);
&format_inherited($inherited);
&format_percentages($percentages);
&format_media($media);
print output "</TABLE>\n";
print output "</DIV>\n\n";
}
sub format_name {
print output "<TR valign=\"top\"><TH align=\"right\">Property name:";
print output "<TD><span class=\"index-def\" title=\"'$_[0]'\">\'$_[0]\'</span></TR>\n";
}
sub format_values {
$values = $_[0];
$values =~ s/<([^>']*)>/<span class=\"value-inst-$1\"><$1><\/span>/g;
$values =~ s/<[']([^']*)[']>/<span class=\"propinst-$1\"><'$1'><\/span>/g;
print output "<TR valign=\"top\"><TH align=\"right\">Value:<TD>$values</TR>\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=\"top\"><TH align=\"right\">Initial:<TD>$init</TR>\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=\"top\"><TH align=\"right\">Applies to:<TD>$applies</TR>\n";
}
sub format_inherited {
print output "<TR valign=\"top\"><TH align=\"right\">Inherited:<TD>$_[0]</TR>\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=\"top\"><TH align=\"right\">Percentage values:<TD>$perc</TR>\n";
}
sub format_media {
$fmedia = $_[0];
$fmedia =~ s/p_c/<a href=\"media.html#p_c-media-group\">p_c<\/a>/;
$fmedia =~ s/g_b/<a href=\"media.html#g_b-media-group\">g_b<\/a>/;
$fmedia =~ s/v_a_t/<a href=\"media.html#v_a_t-media-group\">v_a_t<\/a>/;
$fmedia =~ s/visual/<a href=\"media.html#visual-media-group\">visual<\/a>/;
$fmedia =~ s/aural/<a href=\"media.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/all/<a href=\"media.html#all-media-group\">all<\/a>/;
print output "<TR valign=\"top\"><TH align=\"right\">Media groups:<TD>$fmedia</TR>\n";
}
# extract every possible block
$_ = $buf;
while (/$blockst$patt;;$patt;;$patt;;$patt;;$patt;;$patt;;$patt$blocket/s) {
# Set parameters first (before any modifications)
$placeholder = $';
$output = "$path$1.srb";
print "\textracting $output\n";
open(output, "> $output");
&format_property($1, $2, $3, $4, $5, $6, $7);
close(output);
$_ = $placeholder;
}