Skip to content

Commit b3afc4d

Browse files
committed
[css2] Added property/value links. Index modifs.
--HG-- extra : convert_revision : svn%3A73dc7c4b-06e6-40f3-b4f7-9ed1dbc14bfc/trunk%4027
1 parent 40b9a3a commit b3afc4d

7 files changed

Lines changed: 278 additions & 43 deletions

File tree

css2/Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Makefile to generate the CSS2 document based on its "source files"
22
# Arnaud Le Hors - lehors@w3.org
3-
# $Id: Makefile,v 1.6 1997-08-05 17:30:45 ijacobs Exp $
3+
# $Id: Makefile,v 1.7 1997-08-06 14:03:15 ijacobs Exp $
44

55
ROOT = .
66

@@ -97,7 +97,7 @@ HMKDEPEND= $(PERL) ./bin/hmkdep
9797
# make property anchor database
9898
MKANCHDB= $(PERL) ./bin/mkanchdb
9999
# add heading anchors
100-
ADDHANCH= $(PERL) ./bin/addhanch -n -ml 3
100+
ADDHANCH= $(PERL) ./bin/addhanch -n -ml 4
101101
# add index anchors and generate related index database
102102
ADDIDXANCH= $(PERL) ./bin/addianch
103103
# add navigation bars
@@ -112,6 +112,8 @@ HTMLCAT= $(PERL) ./bin/htmlcat
112112
MKSUBTOC= $(PERL) ./bin/mksubtoc
113113
# insert subtoc
114114
INSAFTER= $(PERL) ./bin/insafter
115+
# add link
116+
ADDLINKS= $(PERL) ./bin/addlinks
115117

116118
# utility to generate the PostScript version
117119
HTML2PSARGS= -n -D -R
@@ -136,6 +138,7 @@ LN= ln
136138
echo "</div>" >> build/subtoc.$$$$; \
137139
$(HIPP) $(INCLUDES) $< - | $(ADDHANCH) -r $< - - $(HEADINGDB) | \
138140
$(ADDIDXANCH) -r $< - - build/index/$<.db | \
141+
$(ADDLINKS) -r $< - - propinst $(PROPERTYDB) value-inst $(VALUEDB) | \
139142
$(ADDNAVBAR) -r $@ - - contents "cover.html#toc" index index.html| \
140143
$(INSAFTER) - build/subtoc.$$$$ /H1 $@; \
141144
$(RM) build/subtoc.$$$$
@@ -185,7 +188,7 @@ css20.zip:
185188

186189
$(PROPERTYDB): $(SPECSRCS)
187190
@if [ ! -d build ]; then mkdir build;fi
188-
$(MKANCHDB) index-def - $(SPECSRCS) | sed 's/\.src/\.html/' > $@
191+
$(MKANCHDB) propdef - $(SPECSRCS) | sed 's/\.src/\.html/' > $@
189192

190193
$(VALUEDB): $(SPECSRCS)
191194
$(MKANCHDB) value-def - $(SPECSRCS) | sed 's/\.src/\.html/' > $@

css2/bin/Attic/addlinks

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/usr/local/bin/perl
2+
# Add links from instances to definitions
3+
#
4+
# Arnaud Le Hors - lehors@w3.org
5+
# $Id: addlinks,v 1.1 1997-08-06 14:02:46 ijacobs Exp $
6+
7+
if (($_ = $ARGV[0], /^-r/) && $ARGV[0]) {
8+
shift;
9+
$realpath = $ARGV[0];
10+
shift;
11+
} else {
12+
$realpath = ();
13+
}
14+
15+
$PROGNAME = substr($0, rindex($0, "/") + 1);
16+
17+
if ($#ARGV < 4) {
18+
print STDERR "Usage: $PROGNAME [-r realpath] src trgt class anchordb class2 anchordb2 ...\n";
19+
exit 1;
20+
} else {
21+
$input = $ARGV[0];
22+
shift;
23+
if (! $realpath) {
24+
$realpath = $input;
25+
}
26+
$output = $ARGV[0];
27+
shift;
28+
}
29+
30+
31+
# compute relative path from 1 to 2
32+
sub rpath {
33+
@path1 = split("/", $_[0]);
34+
@path2 = split("/", $_[1]);
35+
36+
pop(@path1);
37+
while ($path1[0] eq $path2[0]) {
38+
shift(@path1);
39+
shift(@path2);
40+
}
41+
42+
$root = "";
43+
foreach $el (@path1) {
44+
$root .= "../";
45+
}
46+
$path = join("/", @path2);
47+
return "$root$path";
48+
}
49+
50+
# copy file in memory
51+
sub readfile {
52+
$buf = "";
53+
if (!open(INPUT, $_[0])) {
54+
print STDERR "$PROGNAME Error: Cannot open file: $_[0]\n";
55+
exit 1;
56+
}
57+
while (<INPUT>) {
58+
$buf .= $_;
59+
}
60+
close(INPUT);
61+
}
62+
63+
# given the regexp either both elem1 and elem2 are empty strings
64+
# or one or the other is, but in no case both are non empty
65+
# so we can concatenate them both together
66+
# args: start_tag key contents end_tag
67+
sub addlink {
68+
if (($link = $adbase{lc("$_[1]")})) {
69+
$rlink = rpath($realpath, $link);
70+
return "<a href=\"$rlink\">$_[0]$_[2]$_[3]</a>";
71+
} else { # no anchor found, leave it unchanged
72+
return "$_[0]$_[2]$_[3]";
73+
}
74+
}
75+
76+
# read anchor database
77+
sub readadb {
78+
$adbasef = $_[0];
79+
%adbase = ();
80+
if (!open(DBASE, $adbasef)) {
81+
print STDERR "$PROGNAME Error: Cannot open anchordb: $adbasef\n";
82+
} else {
83+
while (<DBASE>) {
84+
chop;
85+
($key, $data) = split(";", $_, 2);
86+
$adbase{lc($key)} = $data;
87+
}
88+
close(DBASE);
89+
}
90+
}
91+
92+
93+
### main
94+
$wd = "[^ \t\n]+"; # word
95+
$etag="</span>";
96+
97+
readfile($input);
98+
while ($class = $ARGV[0]) {
99+
shift;
100+
readadb($ARGV[0]);
101+
shift;
102+
# insert appropriate links
103+
$stag="<span[ \t\n]*class=$class-($wd)>|<span[ \t\n]*class=\"$class-($wd)\">";
104+
$buf =~ s/($stag)(.*?)($etag)/addlink($1, "$2$3", $4, $5)/sgie;
105+
}
106+
107+
# print out result
108+
open(OUTPUT, "> $output");
109+
print OUTPUT $buf;
110+
close(OUTPUT);

css2/bin/Attic/mkidx

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Table headers can be specified through the '-th' option.
88
#
99
# Arnaud Le Hors - lehors@w3.org
10-
# $Id: mkidx,v 1.6 1997-08-01 17:03:11 ijacobs Exp $
10+
# $Id: mkidx,v 1.7 1997-08-06 14:02:57 ijacobs Exp $
1111

1212
$PROGNAME = substr($0, rindex($0, "/") + 1);
1313

@@ -32,6 +32,8 @@ sub readdbfile {
3232
$index =~ s/^&[^;]+;//;
3333
# Sort on certain chars only.
3434
$index =~ s/^[^a-zA-Z0-9\@:]*//;
35+
# Case-insensitive
36+
$index = lc($index);
3537
$key = "$index$cmt";
3638
if ($indexes{$key}) {
3739
push(@{$indexes{$key}}, "$_");
@@ -50,7 +52,8 @@ foreach $file (@ARGV) {
5052
}
5153

5254
# print out index document
53-
open(OUTPUT, "> $indexf");
55+
$buf = "";
56+
@letters = ();
5457
$curindex = ();
5558
$curletter = ();
5659
foreach $key (sort(keys %indexes)) {
@@ -60,15 +63,16 @@ foreach $key (sort(keys %indexes)) {
6063
($index, $url, $cmt) = split(/\|/, $item, 3);
6164

6265
if (($curindex) && ($curindex ne $index)) {
63-
print OUTPUT "</dl>\n";
66+
$buf .= "</dl>\n";
6467
}
6568
if ($curletter ne ($letter = lc(substr($key, 0, 1)))) {
6669
$curletter = $letter;
67-
print OUTPUT "<h2><a name=\"$letter\">" .
70+
$buf .= "<h2><a name=\"$letter\">" .
6871
uc($letter) . "</a></h2>\n";
72+
push(@letters, $letter);
6973
}
7074
if ($curindex ne $index) {
71-
print OUTPUT "\n<dl><dt>$index";
75+
$buf .= "\n<dl><dt>$index";
7276
$n = 1;
7377
$curindex = $index;
7478
}
@@ -78,7 +82,7 @@ foreach $key (sort(keys %indexes)) {
7882
# If the subkey is not the same
7983
# as the previous one, start
8084
# a new subkey list.
81-
print OUTPUT "\n<dd> $cmt";
85+
$buf .= "\n<dd> $cmt";
8286
$pre = "\n, <a href=\"$url\">";
8387
$content = "1";
8488
$post = "</a>";
@@ -102,8 +106,20 @@ foreach $key (sort(keys %indexes)) {
102106
if (/\#didx-/) {
103107
$content = "<em>$content</em>";
104108
}
105-
print OUTPUT "$pre$content$post";
109+
$buf .= "$pre$content$post";
106110
}
107111
}
108-
print OUTPUT "</dl>\n";
112+
$buf .= "</dl>\n";
113+
114+
# Print out the full buffer
115+
open(OUTPUT, "> $indexf");
116+
print OUTPUT "<H2><P> ";
117+
foreach $letter (@letters) {
118+
print OUTPUT " <a href=\"#$letter\">" . uc($letter) . "</a> ";
119+
}
120+
print OUTPUT "</H2>";
121+
print OUTPUT $buf;
109122
close(OUTPUT);
123+
124+
125+

css2/bin/Attic/mktoc

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# 1. Some header - and its related comment
66
#
77
# Arnaud Le Hors - lehors@w3.org
8-
# $Id: mktoc,v 1.5 1997-07-31 15:38:28 ijacobs Exp $
8+
# $Id: mktoc,v 1.6 1997-08-06 14:03:04 ijacobs Exp $
99

1010
$PROGNAME = substr($0, rindex($0, "/") + 1);
1111

@@ -89,7 +89,6 @@ foreach $file (@ARGV) {
8989
$hfil =~ s/\.src/\.html/;
9090
# seek headings
9191
$_ = $buf;
92-
$lastlevel = ();
9392
while (/$headingp/sio) {
9493
$h = int($1);
9594
$t = $2;
@@ -106,22 +105,14 @@ foreach $file (@ARGV) {
106105
if ($h == 1) {
107106
print OUTPUT
108107
"<P><a href=\"$url\"$rel><strong>$num $txt</strong></a>\n";
109-
$lastlevel = 1;
110108
} elsif ($h == 2) {
111109
print OUTPUT "<BR><a href=\"$url\"$rel>$num $txt</a>\n";
112-
$lastlevel = 2;
113110
} elsif ($h == 3) {
114111
print OUTPUT
115112
"<BR>&nbsp;&nbsp;&nbsp;<a href=\"$url\"$rel>$num $txt</a>\n";
116-
$lastlevel = 3;
117113
} else {
118-
if ($lastlevel < 4) {
119-
print OUTPUT "<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
120-
} else {
121-
print OUTPUT ", &nbsp;"
122-
}
123-
print OUTPUT "<a href=\"$url\"$rel>$txt</a>";
124-
$lastlevel = 4;
114+
print OUTPUT
115+
"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"$url\"$rel>$txt</a>\n";
125116
}
126117
#Print comment about section contents.
127118
if ($3) {

css2/bin/addlinks

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/usr/local/bin/perl
2+
# Add links from instances to definitions
3+
#
4+
# Arnaud Le Hors - lehors@w3.org
5+
# $Id: addlinks,v 1.1 1997-08-06 14:02:46 ijacobs Exp $
6+
7+
if (($_ = $ARGV[0], /^-r/) && $ARGV[0]) {
8+
shift;
9+
$realpath = $ARGV[0];
10+
shift;
11+
} else {
12+
$realpath = ();
13+
}
14+
15+
$PROGNAME = substr($0, rindex($0, "/") + 1);
16+
17+
if ($#ARGV < 4) {
18+
print STDERR "Usage: $PROGNAME [-r realpath] src trgt class anchordb class2 anchordb2 ...\n";
19+
exit 1;
20+
} else {
21+
$input = $ARGV[0];
22+
shift;
23+
if (! $realpath) {
24+
$realpath = $input;
25+
}
26+
$output = $ARGV[0];
27+
shift;
28+
}
29+
30+
31+
# compute relative path from 1 to 2
32+
sub rpath {
33+
@path1 = split("/", $_[0]);
34+
@path2 = split("/", $_[1]);
35+
36+
pop(@path1);
37+
while ($path1[0] eq $path2[0]) {
38+
shift(@path1);
39+
shift(@path2);
40+
}
41+
42+
$root = "";
43+
foreach $el (@path1) {
44+
$root .= "../";
45+
}
46+
$path = join("/", @path2);
47+
return "$root$path";
48+
}
49+
50+
# copy file in memory
51+
sub readfile {
52+
$buf = "";
53+
if (!open(INPUT, $_[0])) {
54+
print STDERR "$PROGNAME Error: Cannot open file: $_[0]\n";
55+
exit 1;
56+
}
57+
while (<INPUT>) {
58+
$buf .= $_;
59+
}
60+
close(INPUT);
61+
}
62+
63+
# given the regexp either both elem1 and elem2 are empty strings
64+
# or one or the other is, but in no case both are non empty
65+
# so we can concatenate them both together
66+
# args: start_tag key contents end_tag
67+
sub addlink {
68+
if (($link = $adbase{lc("$_[1]")})) {
69+
$rlink = rpath($realpath, $link);
70+
return "<a href=\"$rlink\">$_[0]$_[2]$_[3]</a>";
71+
} else { # no anchor found, leave it unchanged
72+
return "$_[0]$_[2]$_[3]";
73+
}
74+
}
75+
76+
# read anchor database
77+
sub readadb {
78+
$adbasef = $_[0];
79+
%adbase = ();
80+
if (!open(DBASE, $adbasef)) {
81+
print STDERR "$PROGNAME Error: Cannot open anchordb: $adbasef\n";
82+
} else {
83+
while (<DBASE>) {
84+
chop;
85+
($key, $data) = split(";", $_, 2);
86+
$adbase{lc($key)} = $data;
87+
}
88+
close(DBASE);
89+
}
90+
}
91+
92+
93+
### main
94+
$wd = "[^ \t\n]+"; # word
95+
$etag="</span>";
96+
97+
readfile($input);
98+
while ($class = $ARGV[0]) {
99+
shift;
100+
readadb($ARGV[0]);
101+
shift;
102+
# insert appropriate links
103+
$stag="<span[ \t\n]*class=$class-($wd)>|<span[ \t\n]*class=\"$class-($wd)\">";
104+
$buf =~ s/($stag)(.*?)($etag)/addlink($1, "$2$3", $4, $5)/sgie;
105+
}
106+
107+
# print out result
108+
open(OUTPUT, "> $output");
109+
print OUTPUT $buf;
110+
close(OUTPUT);

0 commit comments

Comments
 (0)