Skip to content

Commit 9d9eb42

Browse files
committed
[css2] Added. New files to support new perl scripts.
--HG-- extra : convert_revision : svn%3A73dc7c4b-06e6-40f3-b4f7-9ed1dbc14bfc/trunk%40795
1 parent 1856d86 commit 9d9eb42

File tree

5 files changed

+449
-0
lines changed

5 files changed

+449
-0
lines changed

css2/Project.cfg

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Configuration file for CSS2 spec project
2+
#
3+
# This file contains the order of chapters,
4+
# the style sheet to use,
5+
# the name of the file with the ToC,
6+
# the numbering styles for each chapter,
7+
# and maybe more.
8+
# To be processed by bin/mkchain, and maybe others.
9+
# Quotes around values are optional, unless the
10+
# value contains spaces.
11+
#
12+
# Bert Bos <bert@w3.org>
13+
# $Id: Project.cfg,v 1.2 1998-02-02 19:05:46 bbos Exp $
14+
15+
@source-extension .src
16+
17+
@stylesheet style/default.css type/css
18+
@contents "cover.html#toc"
19+
20+
# Additional links. If for navbar, then add a 3rd column
21+
@link CSS-properties propidx.html "properties"
22+
@link CSS-descriptors descidx.html "descriptors"
23+
@link index indexlist.html "index"
24+
25+
@format "" "" "" "" "" ""
26+
@chapter cover.html
27+
28+
@format "1" "1.1" "1.1.1" "" "" ""
29+
@chapter about.html
30+
@chapter intro.html
31+
@chapter conform.html
32+
@chapter syndata.html
33+
@chapter selector.html
34+
@chapter cascade.html
35+
@chapter media.html
36+
@chapter visuren.html
37+
@chapter visudet.html
38+
@chapter visufx.html
39+
@chapter generate.html
40+
@chapter page.html
41+
@chapter colors.html
42+
@chapter fonts.html
43+
@chapter text.html
44+
@chapter lists.html
45+
@chapter tables.html
46+
@chapter ui.html
47+
@chapter aural.html
48+
49+
@format "\Append\ix A." "A.1" "A.1.1" "" "" ""
50+
@chapter sample.html
51+
@chapter changes.html
52+
@chapter notes.html
53+
@chapter grammar.html
54+
@chapter refs.html
55+
@chapter propidx.html
56+
@chapter descidx.html
57+
@chapter indexlist.html

css2/bin/Attic/mkchain

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/local/bin/perl
2+
#
3+
# Insert Next, ToC & Prev links.
4+
#
5+
# The given configuration file contains ordering and
6+
# numbering information:
7+
#
8+
# Bert Bos <bert@w3.org>
9+
# $Id: mkchain,v 1.2 1998-02-02 19:06:19 bbos Exp $
10+
11+
use Getopt::Std;
12+
use lib 'bin';
13+
use utils;
14+
15+
my $PROG = substr($0, rindex($0, "/") + 1);
16+
my $USAGE = "Usage: $PROG [-r real-name] [-c configfile] [file [output]]\n";
17+
18+
19+
getopts('r:c:') or die $USAGE;
20+
if ($#ARGV >= 0) {$input = $ARGV[0]; shift;} else {$input = '-';}
21+
if ($#ARGV >= 0) {$output = $ARGV[0]; shift;} else {$output = '-';}
22+
if ($#ARGV >= 0) {die $USAGE;}
23+
24+
my $name = defined $opt_r ? $opt_r : $input;
25+
my $configfile = defined $opt_c ? $opt_c : 'Project.cfg';
26+
27+
# Read configuratio and find info about current file
28+
read_config($configfile);
29+
30+
defined $lookup{$name} or die "$PROG: $name not found in config file\n";
31+
$chapno = $lookup{$name};
32+
33+
# Insert the links after the </TITLE> tag. (There better be one!)
34+
open(IN, $input) or die "$PROG: cannot read file $input\n";
35+
open(OUT, ">$output") or die "$PROG: cannot write to file $output\n";
36+
my $done = 0;
37+
38+
while (<IN>) {
39+
/<\/title[^>]*>/io and do {
40+
print OUT $`;
41+
print OUT $&;
42+
if ($stylesheet ne '') {
43+
print OUT "\n<link rel=\"stylesheet\" href=\"$stylesheet\"";
44+
if ($styletype ne '') {print OUT " type=\"$styletype\"";}
45+
print OUT ">";
46+
}
47+
if ($chapno > 0) {
48+
print OUT "\n<link rel=\"prev\" href=\"$chapter[$chapno-1]\">";
49+
}
50+
if ($chapno < $#chapter) {
51+
print OUT "\n<link rel=\"next\" href=\"$chapter[$chapno+1]\">";
52+
}
53+
if ($contents ne '') {
54+
print OUT "\n<link rel=\"contents\" href=\"$contents\">";
55+
}
56+
for ($i = 0; $i <= $#links; $i++) {
57+
print OUT "\n<link rel=\"$relations[$i]\" href=\"$links[$i]\"";
58+
if ($tonavbar[$i] ne '') {print OUT " title=\"$tonavbar[$i]\"";}
59+
print OUT ">";
60+
}
61+
print OUT $';
62+
$done = 1;
63+
last;
64+
};
65+
print OUT;
66+
}
67+
68+
# Copy the rest of the file
69+
while (<IN>) {
70+
print OUT;
71+
}
72+
73+
if (! $done) {die "$PROG: $input had no <TITLE>; no links inserted\n";}
74+
75+
# Finalize
76+
close(IN);
77+
close(OUT);

css2/bin/Attic/utils.pm

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# -*-perl-*-
2+
3+
package utils;
4+
require Exporter;
5+
@ISA = qw(Exporter);
6+
@EXPORT = qw(readfile writefile read_config $contents $stylesheet
7+
$styletype @chapter @resetnumber @format %lookup $chapno @relations
8+
@links @tonavbar $src_ext);
9+
10+
# @EXPORT_OK = qw();
11+
12+
13+
# use Text::ParseWords;
14+
15+
$contents = ''; # File containing ToC
16+
$stylesheet = ''; # URL of style sheet
17+
$styletype = ''; # MIME type of style sheet
18+
@chapter = (); # Array of chapter files
19+
@resetnumber = (); # For each chapter: the chapter number - 1
20+
@format = (); # For each chapter: list of number formats
21+
%lookup = (); # Reverse index: chapter name -> number
22+
$chapno = -1; # Number of the chapter under consideration
23+
@relations = (); # Additional links
24+
@links = (); # Additional links (paired with @relations)
25+
@tonavbar = (); # Whether the link goes into the navbar
26+
$src_ext = undef; # Extension of source files
27+
28+
sub parsewords {
29+
my $line = $_[0];
30+
my @words = ();
31+
while ($line ne '') {
32+
if ($line =~ /^\s+/) {
33+
# Skip whitespace
34+
} elsif ($line =~ /^\"((?:[^\"]|\\\")*)\"/) {
35+
push(@words, $1);
36+
} elsif ($line =~ /^\'((?:[^\']|\\\')*)\'/) {
37+
push(@words, $1);
38+
} elsif ($line =~ /^\S+/) {
39+
push(@words, $&);
40+
} else {
41+
die "Cannot happen\n";
42+
}
43+
$line = $';
44+
}
45+
return @words;
46+
}
47+
48+
# Read info about book's structure from $_[0]
49+
sub read_config {
50+
open(IN, $_[0]) || die "$0: cannot open file $_[0]\n";
51+
my $reset = 0; # If >= 0, start chapter numbering w/ this
52+
my @curformat = ("1","1.1","1.1.1","1.1.1.1","1.1.1.1.1","1.1.1.1.1.1");
53+
while (<IN>) {
54+
chop;
55+
my @words = parsewords($_);
56+
if (!defined $words[0]) {next;} # Empty line
57+
for ($words[0]) {
58+
/\@contents$/o and do { # URL of ToC
59+
$contents = $words[1];
60+
last;
61+
};
62+
/\@stylesheet$/o and do { # URL (and type) of style sheet
63+
$stylesheet = $words[1];
64+
if (defined $words[2]) {$styletype = $words[2];}
65+
last;
66+
};
67+
/\@format$/o and do { # Set numbering style for next chapters
68+
@curformat = @words;
69+
$reset = 0;
70+
last;
71+
};
72+
/\@restart$/o and do { # Reset the chapter number
73+
$reset = int($words[1]) - 1;
74+
next;
75+
};
76+
/\@chapter$/o and do { # File with next chapter
77+
push(@chapter, ($words[1]));
78+
push(@format, ([@curformat]));
79+
push(@resetnumber, ($reset));
80+
$reset++;
81+
$lookup{$words[1]} = $#chapter;
82+
last;
83+
};
84+
/\@link$/o and do { # Additional <LINK> tags
85+
push(@relations, ($words[1]));
86+
push(@links, ($words[2]));
87+
push(@tonavbar, (defined $words[3] ? $words[3] : ""));
88+
last;
89+
};
90+
/\@source-extension$/o and do { # Extension of sources
91+
$src_ext = $words[1];
92+
last;
93+
};
94+
/^\#/o and do { # Comment
95+
last;
96+
};
97+
die "$0: syntax error in config file $_[0], line $.\n";
98+
}
99+
}
100+
close(IN);
101+
}
102+
103+
# Load file into memory
104+
sub readfile {
105+
open(INPUT, $_[0]) || die "$PROG: cannot open file $_[0]\n";
106+
local $/ = undef;
107+
my $buf = <INPUT>;
108+
close(INPUT);
109+
return $buf;
110+
}
111+
112+
# Create a file $_[0] containing $_[1]
113+
sub writefile {
114+
open(OUTPUT, ">$_[0]") || die "$PROG: cannot create file $_[0]\n";
115+
print OUTPUT $_[1];
116+
close(OUTPUT);
117+
}
118+
119+
return 1;

css2/bin/mkchain

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/local/bin/perl
2+
#
3+
# Insert Next, ToC & Prev links.
4+
#
5+
# The given configuration file contains ordering and
6+
# numbering information:
7+
#
8+
# Bert Bos <bert@w3.org>
9+
# $Id: mkchain,v 1.2 1998-02-02 19:06:19 bbos Exp $
10+
11+
use Getopt::Std;
12+
use lib 'bin';
13+
use utils;
14+
15+
my $PROG = substr($0, rindex($0, "/") + 1);
16+
my $USAGE = "Usage: $PROG [-r real-name] [-c configfile] [file [output]]\n";
17+
18+
19+
getopts('r:c:') or die $USAGE;
20+
if ($#ARGV >= 0) {$input = $ARGV[0]; shift;} else {$input = '-';}
21+
if ($#ARGV >= 0) {$output = $ARGV[0]; shift;} else {$output = '-';}
22+
if ($#ARGV >= 0) {die $USAGE;}
23+
24+
my $name = defined $opt_r ? $opt_r : $input;
25+
my $configfile = defined $opt_c ? $opt_c : 'Project.cfg';
26+
27+
# Read configuratio and find info about current file
28+
read_config($configfile);
29+
30+
defined $lookup{$name} or die "$PROG: $name not found in config file\n";
31+
$chapno = $lookup{$name};
32+
33+
# Insert the links after the </TITLE> tag. (There better be one!)
34+
open(IN, $input) or die "$PROG: cannot read file $input\n";
35+
open(OUT, ">$output") or die "$PROG: cannot write to file $output\n";
36+
my $done = 0;
37+
38+
while (<IN>) {
39+
/<\/title[^>]*>/io and do {
40+
print OUT $`;
41+
print OUT $&;
42+
if ($stylesheet ne '') {
43+
print OUT "\n<link rel=\"stylesheet\" href=\"$stylesheet\"";
44+
if ($styletype ne '') {print OUT " type=\"$styletype\"";}
45+
print OUT ">";
46+
}
47+
if ($chapno > 0) {
48+
print OUT "\n<link rel=\"prev\" href=\"$chapter[$chapno-1]\">";
49+
}
50+
if ($chapno < $#chapter) {
51+
print OUT "\n<link rel=\"next\" href=\"$chapter[$chapno+1]\">";
52+
}
53+
if ($contents ne '') {
54+
print OUT "\n<link rel=\"contents\" href=\"$contents\">";
55+
}
56+
for ($i = 0; $i <= $#links; $i++) {
57+
print OUT "\n<link rel=\"$relations[$i]\" href=\"$links[$i]\"";
58+
if ($tonavbar[$i] ne '') {print OUT " title=\"$tonavbar[$i]\"";}
59+
print OUT ">";
60+
}
61+
print OUT $';
62+
$done = 1;
63+
last;
64+
};
65+
print OUT;
66+
}
67+
68+
# Copy the rest of the file
69+
while (<IN>) {
70+
print OUT;
71+
}
72+
73+
if (! $done) {die "$PROG: $input had no <TITLE>; no links inserted\n";}
74+
75+
# Finalize
76+
close(IN);
77+
close(OUT);

0 commit comments

Comments
 (0)