Skip to content

Commit 4ed309a

Browse files
committed
[css2] Extract property data from database into individual files. Format
--HG-- extra : convert_revision : svn%3A73dc7c4b-06e6-40f3-b4f7-9ed1dbc14bfc/trunk%4054
1 parent 9201eb4 commit 4ed309a

2 files changed

Lines changed: 226 additions & 0 deletions

File tree

css2/bin/Attic/pextr

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#!/usr/local/bin/perl
2+
# Extract entries from the CSS properties database
3+
# The database has the following format:
4+
# name;; values;; initial-value;; applies-to;; inherited;; percentages
5+
# Special characters:
6+
# 1) Translate "*" into the words "all elements"
7+
# 1.a) Translate "XX" into "not defined for shorthand properties"
8+
# 2) "<name>" means the value is defined elsewhere. Translate to
9+
# <span class="value-inst-name">&lt;name&gt;</span>
10+
# 3) "<'name'>" means the set of values is the same as for the
11+
# property with the same name. Translate to
12+
# <span class="propinst-name">&lt;'name'&gt;</span>
13+
#
14+
# Ian Jacobs - ij@w3.org (Based on work by Arnaud Le Hors)
15+
# $Id: pextr,v 1.1 1997-09-08 18:24:13 ian Exp $
16+
17+
$PROGNAME = substr($0, rindex($0, "/") + 1);
18+
19+
if (!$ARGV[0]) {
20+
print "Usage: $PROGNAME file [tgt_dir]\n";
21+
exit 1;
22+
}
23+
24+
# copy file in memory
25+
if (!open(input, $ARGV[0])) {
26+
print "$PROGNAME Error: Cannot open file: $ARGV[0]\n";
27+
exit 1;
28+
}
29+
$buf = "";
30+
while (<input>) {
31+
$buf .= $_;
32+
}
33+
close(input);
34+
35+
$path = "";
36+
if ($ARGV[1]) {
37+
$path = "$ARGV[1]/";
38+
}
39+
40+
# regexps
41+
$sp = "[ \t\n]*"; # whitespace
42+
$patt = "$sp(.*?)$sp";
43+
$blockst = "[/][*]";
44+
$blocket = "[*][/]";
45+
46+
sub format_property {
47+
$name = $_[0];
48+
$values = $_[1];
49+
$init = $_[2];
50+
$applies = $_[3];
51+
$inherited = $_[4];
52+
$percentages = $_[5];
53+
print output "<DIV class=\"propdef\">\n";
54+
print output "<H4 class=\"propname\">\n";
55+
print output "<a name=\"propdef-$name\">'$name'</a>\n";
56+
print output "</H4>\n";
57+
print output "<TABLE class=\"propinfo\">\n";
58+
&format_name($name);
59+
&format_values($values);
60+
&format_init($init);
61+
&format_applies($applies);
62+
&format_inherited($inherited);
63+
&format_percentages($percentages);
64+
print output "</TABLE>\n";
65+
print output "</DIV>\n\n";
66+
}
67+
68+
sub format_name {
69+
print output "<TR><TH align=\"right\">Property name:";
70+
print output "<TD><span class=\"index-def\" title=\"'$_[0]'\">\'$_[0]\'</span></TR>\n";
71+
}
72+
73+
sub format_values {
74+
$values = $_[0];
75+
$values =~ s/<([^>']*)>/<span class=\"value-inst-$1\">&lt;$1&gt;<\/span>/g;
76+
$values =~ s/<[']([^']*)[']>/<span class=\"propinst-$1\">&lt;'$1'&gt;<\/span>/g;
77+
print output "<TR><TH align=\"right\">Value:<TD>$values</TR>\n";
78+
}
79+
80+
sub format_init {
81+
$init = $_[0];
82+
$init =~ s/XX/not defined for shorthand properties/g;
83+
$init =~ s/<([^>']*)>/<span class=\"value-inst-$1\">&lt;$1&gt;<\/span>/g;
84+
$init =~ s/<[']([^']*)[']>/<span class=\"propinst-$1\">&lt;'$1'&gt;<\/span>/g;
85+
print output "<TR><TH align=\"right\">Initial:<TD>$init</TR>\n";
86+
}
87+
88+
sub format_applies {
89+
$applies = $_[0];
90+
$applies =~ s/\*/all elements/g;
91+
print output "<TR><TH align=\"right\">Applies to:<TD>$applies</TR>\n";
92+
}
93+
94+
sub format_inherited {
95+
print output "<TR><TH align=\"right\">Inherited:<TD>$_[0]</TR>\n";
96+
}
97+
98+
sub format_percentages {
99+
print output "<TR><TH align=\"right\">Percentage values:<TD>$_[0]</TR>\n";
100+
}
101+
102+
# extract every possible block
103+
$_ = $buf;
104+
while (/$blockst$patt;;$patt;;$patt;;$patt;;$patt;;$patt$blocket/s) {
105+
# Set parameters first (before any modifications)
106+
$placeholder = $';
107+
$output = "$path$1.srb";
108+
print "\textracting $output\n";
109+
open(output, "> $output");
110+
&format_property($1, $2, $3, $4, $5, $6);
111+
close(output);
112+
$_ = $placeholder;
113+
}

css2/bin/pextr

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#!/usr/local/bin/perl
2+
# Extract entries from the CSS properties database
3+
# The database has the following format:
4+
# name;; values;; initial-value;; applies-to;; inherited;; percentages
5+
# Special characters:
6+
# 1) Translate "*" into the words "all elements"
7+
# 1.a) Translate "XX" into "not defined for shorthand properties"
8+
# 2) "<name>" means the value is defined elsewhere. Translate to
9+
# <span class="value-inst-name">&lt;name&gt;</span>
10+
# 3) "<'name'>" means the set of values is the same as for the
11+
# property with the same name. Translate to
12+
# <span class="propinst-name">&lt;'name'&gt;</span>
13+
#
14+
# Ian Jacobs - ij@w3.org (Based on work by Arnaud Le Hors)
15+
# $Id: pextr,v 1.1 1997-09-08 18:24:13 ian Exp $
16+
17+
$PROGNAME = substr($0, rindex($0, "/") + 1);
18+
19+
if (!$ARGV[0]) {
20+
print "Usage: $PROGNAME file [tgt_dir]\n";
21+
exit 1;
22+
}
23+
24+
# copy file in memory
25+
if (!open(input, $ARGV[0])) {
26+
print "$PROGNAME Error: Cannot open file: $ARGV[0]\n";
27+
exit 1;
28+
}
29+
$buf = "";
30+
while (<input>) {
31+
$buf .= $_;
32+
}
33+
close(input);
34+
35+
$path = "";
36+
if ($ARGV[1]) {
37+
$path = "$ARGV[1]/";
38+
}
39+
40+
# regexps
41+
$sp = "[ \t\n]*"; # whitespace
42+
$patt = "$sp(.*?)$sp";
43+
$blockst = "[/][*]";
44+
$blocket = "[*][/]";
45+
46+
sub format_property {
47+
$name = $_[0];
48+
$values = $_[1];
49+
$init = $_[2];
50+
$applies = $_[3];
51+
$inherited = $_[4];
52+
$percentages = $_[5];
53+
print output "<DIV class=\"propdef\">\n";
54+
print output "<H4 class=\"propname\">\n";
55+
print output "<a name=\"propdef-$name\">'$name'</a>\n";
56+
print output "</H4>\n";
57+
print output "<TABLE class=\"propinfo\">\n";
58+
&format_name($name);
59+
&format_values($values);
60+
&format_init($init);
61+
&format_applies($applies);
62+
&format_inherited($inherited);
63+
&format_percentages($percentages);
64+
print output "</TABLE>\n";
65+
print output "</DIV>\n\n";
66+
}
67+
68+
sub format_name {
69+
print output "<TR><TH align=\"right\">Property name:";
70+
print output "<TD><span class=\"index-def\" title=\"'$_[0]'\">\'$_[0]\'</span></TR>\n";
71+
}
72+
73+
sub format_values {
74+
$values = $_[0];
75+
$values =~ s/<([^>']*)>/<span class=\"value-inst-$1\">&lt;$1&gt;<\/span>/g;
76+
$values =~ s/<[']([^']*)[']>/<span class=\"propinst-$1\">&lt;'$1'&gt;<\/span>/g;
77+
print output "<TR><TH align=\"right\">Value:<TD>$values</TR>\n";
78+
}
79+
80+
sub format_init {
81+
$init = $_[0];
82+
$init =~ s/XX/not defined for shorthand properties/g;
83+
$init =~ s/<([^>']*)>/<span class=\"value-inst-$1\">&lt;$1&gt;<\/span>/g;
84+
$init =~ s/<[']([^']*)[']>/<span class=\"propinst-$1\">&lt;'$1'&gt;<\/span>/g;
85+
print output "<TR><TH align=\"right\">Initial:<TD>$init</TR>\n";
86+
}
87+
88+
sub format_applies {
89+
$applies = $_[0];
90+
$applies =~ s/\*/all elements/g;
91+
print output "<TR><TH align=\"right\">Applies to:<TD>$applies</TR>\n";
92+
}
93+
94+
sub format_inherited {
95+
print output "<TR><TH align=\"right\">Inherited:<TD>$_[0]</TR>\n";
96+
}
97+
98+
sub format_percentages {
99+
print output "<TR><TH align=\"right\">Percentage values:<TD>$_[0]</TR>\n";
100+
}
101+
102+
# extract every possible block
103+
$_ = $buf;
104+
while (/$blockst$patt;;$patt;;$patt;;$patt;;$patt;;$patt$blocket/s) {
105+
# Set parameters first (before any modifications)
106+
$placeholder = $';
107+
$output = "$path$1.srb";
108+
print "\textracting $output\n";
109+
open(output, "> $output");
110+
&format_property($1, $2, $3, $4, $5, $6);
111+
close(output);
112+
$_ = $placeholder;
113+
}

0 commit comments

Comments
 (0)