-# Build a references list
-# Needed to link text and tables, images and so on (see figure xxx)
-# with an HTML href
-# IN: root dir and reference filename
-# OUT: a reference file (ako hash)
-# =======================
-sub build_references {
- my $root = $_[0] ;
- my $referencefile = $_[1] ;
- print "Root dir: $root\n" ;
- print "References file: $referencefile" ;
- my %references ;
- my @content ;
- local *FH ;
- for my $i (`find $root -iname "[a-zA-Z0-9]*.aux"`) {
- print "Building references for $i\n" ;
- open FH, "< $i" or die "Unable to open file $i\n" ;
- @content = <FH> ;
- close FH ;
- for $l (@content) {
- if ($l =~ /newlabel/) {
-### \newlabel{figbs6:fdstorageaddress}{{2.1}{15}{Backup Over WAN\relax \relax }{figure.caption.15}{}}
- my @elts = split('{|}',$l) ;
- if ($#elts >4) {
- if ($elts[1] ne "" and $elts[4] ne "") {
- print "Clef: $elts[1]\n" ;
- chomp($i) ;
- chomp($elts[1]) ;
- chomp($elts[4]) ;
- $references{$elts[1]}{anchor} = $elts[4] ;
- $references{$elts[1]}{file} = "" ;
- $references{$elts[4]}{latexref} = $elts[1] ;
- }
- }
- }
- }
- }
- for my $i (`find $root -iname "[a-zA-Z0-9]*.html"`) {
- print "Building anchors for $i\n" ;
- open FH, "< $i" or die "Unable to open file $i\n" ;
- @content = <FH> ;
- close FH ;
- foreach $l (@content) {
-# print "ligne: $l\n" ;
- if ($l =~ m/<A [^>]*NAME *= *"([^>]*)"/) {
- chomp($l) ;
- print "L matche: $l / $1\n" ;
- if (exists $references{$1}{latexref}) {
- print "Bingo: $i --- " . $references{$1}{latexref} . "\n" ;
- $references{$references{$1}{latexref}}{file} = $i ;
- }
- }
- }
- }
- print "Writing references\n" ;
- open FH,"> $referencefile" or die "Unable to create file $referencefile\n" ;
- foreach $k (keys %references) {
- if ($references{$k}{file} ne "") {
- print "Key: $k\n" ;
- print FH $k . " " . $references{$k}{file} . " " . $references{$k}{anchor} . "\n" ;
- }
- }
- close FH ;
- return %references ;
-}
-#
-# References reading method
-# To be able to handle references accross HTML files
-# =========================
-sub read_references {
- my $referencefile = $_[0] ;
- my %references ;
- local *FH ;
- open FH, "< $referencefile" or die "Unable to open $referencefile\n" ;
- while (<FH>) {
- our($k,$f,$v) = split / /,$_ ;
- $refences{$k}{file} = $f ;
- $refences{$k}{anchor} = $v ;
- }
- close FH ;
- return %refences ;
-}
-#