26.7 Escape String for Hyperref

Produce a string that can serve as hyperref index.

Note that we cannot simply replace parenthesis by open and closing brackets, since the generated output is going to be fed to NOWEAVE. Double opening brackets would cause problems.

327auxiliary subroutines 305b+   (330)  305b  328a
sub escapeForHyperref {
    my($s)=@_;
    $s =~ s/\s//g;
    $s =~ s/(\(|{)/\[./g;
    $s =~ s/(\)|})/.\]/g;
    $s =~ s/%/PER/g;
    $s =~ s/_/.0/g;
    $s =~ s/\^/.1/g;
    $s =~ s/~/.2/g;
    $s =~ s/\\/.3/g;
    $s =~s/#/.4/g;
    return $s;
}

Defines:
escapeForHyperref, used in chunks 325 and 328b.