Skip to content

Commit a9de4ac

Browse files
committed
[css2] Added to CVS.
--HG-- extra : convert_revision : svn%3A73dc7c4b-06e6-40f3-b4f7-9ed1dbc14bfc/trunk%40845
1 parent 8b49c22 commit a9de4ac

2 files changed

Lines changed: 174 additions & 0 deletions

File tree

css2/bin/Attic/addcite

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/usr/local/bin/perl -w
2+
#
3+
# Expand references to bibliography:
4+
# replaces [[xxx]] with
5+
# <a href="url-of-xxx">[xxx]</a>
6+
#
7+
# url-of-xxx is constructed from the refsrc file (an
8+
# HTML file with biblio-entries), and the anchors found
9+
# in that file.
10+
#
11+
# Biblio-entries in refsrc must have the form:
12+
# <a ...name="ref-yyy"...>[xxx]</a>
13+
#
14+
# Option -r gives the prefix for anchors, otherwise refsrc
15+
# is used as prefix.
16+
#
17+
# Bert Bos <bert@w3.org>
18+
# $Id: addcite,v 2.1 1998-02-10 17:42:26 bbos Exp $
19+
20+
use Getopt::Std;
21+
use lib 'bin';
22+
use utils;
23+
24+
$PROG = substr($0, rindex($0, "/") + 1);
25+
$USAGE = "Usage: $PROG [-r prefix] refsrc [file [output]]\n";
26+
27+
my %refanch; # Holds cite keys and anchors
28+
my %refclass; # Holds class of reference (normref,...)
29+
30+
31+
# Read the bibliography $_[0], store keys and anchors in hash table $refs
32+
sub read_refs {
33+
my $buf = readfile($_[0]);
34+
while ($buf =~ /(<a\s[^>]*?name\s*=\s*[\"\']?(ref-[^\s\"\'>]*)[\"\']?.*?>)\s*\[(.*?)\]\s*<\/a\b/sio) {
35+
$buf = $';
36+
$stag = $1;
37+
$key = $3;
38+
$refanch{$key} = $2;
39+
40+
# Check for class
41+
if ($stag =~ /\bclass\s*=\s*[\"\']?([^\s\"\'>]+)[\"\']?/) {
42+
$refclass{$key} = $1;
43+
}
44+
}
45+
}
46+
47+
48+
### main
49+
50+
getopts('r:') || die $USAGE;
51+
if ($#ARGV >= 0) {$refsrc = $ARGV[0]; shift;} else {die $USAGE;}
52+
if ($#ARGV >= 0) {$file = $ARGV[0]; shift;} else {$file = '-';}
53+
if ($#ARGV >= 0) {$output = $ARGV[0]; shift;} else {$output = '-';}
54+
if ($#ARGV >= 0) {die $USAGE;}
55+
56+
my $prefix = defined $opt_r ? $opt_r : $refsrc;
57+
58+
read_refs($refsrc);
59+
60+
my $buf = readfile($file);
61+
62+
open(OUT, ">$output") or die "$PROG: cannot write to file $output\n";
63+
64+
# Loop over input, looking for [[xxx]] or [[-xxx]]
65+
while ($buf =~ /\[\[(-)?(\S+?)\]\]/so) {
66+
$buf = $';
67+
print OUT $`;
68+
$firstletter = $1;
69+
$key = $2;
70+
if (! defined $refanch{$key}) {
71+
print STDERR "$PROG: no biblioentry found for [[$key]]\n";
72+
print OUT $&;
73+
} else {
74+
if (defined $firstletter or !defined $refclass{$key}) {
75+
$class = "informref";
76+
} else {
77+
$class = $refclass{$key};
78+
}
79+
print OUT "<a href=\"$prefix#$refanch{$key}\" rel=\"biblioentry\" ";
80+
print OUT "class=\"$class\">[$key]</a>";
81+
}
82+
}
83+
84+
print OUT $buf; # Final part
85+
86+
close(OUT);
87+

css2/bin/addcite

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/usr/local/bin/perl -w
2+
#
3+
# Expand references to bibliography:
4+
# replaces [[xxx]] with
5+
# <a href="url-of-xxx">[xxx]</a>
6+
#
7+
# url-of-xxx is constructed from the refsrc file (an
8+
# HTML file with biblio-entries), and the anchors found
9+
# in that file.
10+
#
11+
# Biblio-entries in refsrc must have the form:
12+
# <a ...name="ref-yyy"...>[xxx]</a>
13+
#
14+
# Option -r gives the prefix for anchors, otherwise refsrc
15+
# is used as prefix.
16+
#
17+
# Bert Bos <bert@w3.org>
18+
# $Id: addcite,v 2.1 1998-02-10 17:42:26 bbos Exp $
19+
20+
use Getopt::Std;
21+
use lib 'bin';
22+
use utils;
23+
24+
$PROG = substr($0, rindex($0, "/") + 1);
25+
$USAGE = "Usage: $PROG [-r prefix] refsrc [file [output]]\n";
26+
27+
my %refanch; # Holds cite keys and anchors
28+
my %refclass; # Holds class of reference (normref,...)
29+
30+
31+
# Read the bibliography $_[0], store keys and anchors in hash table $refs
32+
sub read_refs {
33+
my $buf = readfile($_[0]);
34+
while ($buf =~ /(<a\s[^>]*?name\s*=\s*[\"\']?(ref-[^\s\"\'>]*)[\"\']?.*?>)\s*\[(.*?)\]\s*<\/a\b/sio) {
35+
$buf = $';
36+
$stag = $1;
37+
$key = $3;
38+
$refanch{$key} = $2;
39+
40+
# Check for class
41+
if ($stag =~ /\bclass\s*=\s*[\"\']?([^\s\"\'>]+)[\"\']?/) {
42+
$refclass{$key} = $1;
43+
}
44+
}
45+
}
46+
47+
48+
### main
49+
50+
getopts('r:') || die $USAGE;
51+
if ($#ARGV >= 0) {$refsrc = $ARGV[0]; shift;} else {die $USAGE;}
52+
if ($#ARGV >= 0) {$file = $ARGV[0]; shift;} else {$file = '-';}
53+
if ($#ARGV >= 0) {$output = $ARGV[0]; shift;} else {$output = '-';}
54+
if ($#ARGV >= 0) {die $USAGE;}
55+
56+
my $prefix = defined $opt_r ? $opt_r : $refsrc;
57+
58+
read_refs($refsrc);
59+
60+
my $buf = readfile($file);
61+
62+
open(OUT, ">$output") or die "$PROG: cannot write to file $output\n";
63+
64+
# Loop over input, looking for [[xxx]] or [[-xxx]]
65+
while ($buf =~ /\[\[(-)?(\S+?)\]\]/so) {
66+
$buf = $';
67+
print OUT $`;
68+
$firstletter = $1;
69+
$key = $2;
70+
if (! defined $refanch{$key}) {
71+
print STDERR "$PROG: no biblioentry found for [[$key]]\n";
72+
print OUT $&;
73+
} else {
74+
if (defined $firstletter or !defined $refclass{$key}) {
75+
$class = "informref";
76+
} else {
77+
$class = $refclass{$key};
78+
}
79+
print OUT "<a href=\"$prefix#$refanch{$key}\" rel=\"biblioentry\" ";
80+
print OUT "class=\"$class\">[$key]</a>";
81+
}
82+
}
83+
84+
print OUT $buf; # Final part
85+
86+
close(OUT);
87+

0 commit comments

Comments
 (0)