-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathdextr
More file actions
executable file
·133 lines (120 loc) · 4.19 KB
/
dextr
File metadata and controls
executable file
·133 lines (120 loc) · 4.19 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
#!/usr/local/bin/perl
# Extract entries from the CSS properties database
# The database has the following format:
# name;; values;; initial-value;; 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: dextr,v 1.18 2006-10-09 18:55:52 ihickson 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_descriptor {
my $name = $_[0];
my $values = $_[1];
my $init = $_[2];
my $media = $_[3];
#Do next three lines in src files to get headings right.
print output "<div class=\"descdef\">\n";
print output "<dl><dt>\n";
@names = split(/[, \t\n]+/, $name);
$comma = "";
foreach $n (@names) {
if ($noindex) {
print output "$comma<a name=\"descdef-$n\" class=\"descdef-title\"><strong>'$n'</strong> (Descriptor)</a>";
} else {
print output "$comma<span class=\"index-def\" title=\"'$n' (descriptor)\"><a name=\"descdef-$n\" class=\"descdef-title\"><strong>'$n'</strong> (Descriptor)</a></span>";
}
$comma = ", ";
}
print output "\n<dd>\n";
print output "<table class=\"descinfo\" cellspacing=0 cellpadding=0>\n";
# We use cellspacing/cellpadding until more browsers
# handle tables correctly.
&format_values($values);
&format_init($init);
&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;
print output "<tr valign=baseline>";
print output "<td><em>Value:</em> ";
print output "<td>$values\n";
}
sub format_init {
$init = $_[0];
$init =~ s/XX/not defined for shorthand properties/g;
$init =~ s/<([^>']*)>/<span class=\"value-inst-$1\"><$1><\/span>/g;
print output "<tr valign=baseline>";
print output "<td><em>Initial:</em> ";
print output "<td>$init\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/all/<a href=\"media.html#all-media-group\" class=\"noxref\">all<\/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>/;
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$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_descriptor($1, $2, $3, $4);
close(output);
$_ = $placeholder;
}