#!/usr/bin/perl
#
# Translate Emacs info files into HTML pages, one page per node.
# Menus, Notes, and Up/Next/Prev pointers are translated into links.
# Other text is left as-is in
tags.
#
# Option: -d specifies where to put the output files.
#
# This code is in the public domain. No warranties, express or implied.
#
# Author: Kian-Tat Lim (ktl@wag.caltech.edu), Dec 1993.
# Bugfixes by: Wolfram Schneider , Oct 1997.
#
# $Id: info2html,v 1.3 1997/10/09 11:47:38 wosch Exp wosch $
# parent directory
$up = '..';
# Canonicalize a node name by translating any characters that may give problems
# in an HREF into acceptable alternatives.
sub canon {
local($_) = $_[0];
s/\&/_and_/g;
s|[<>/#? ]|_|g;
s/"/'/g;
return $_;
}
# Translate HTML special characters into escape sequences
sub html {
local($_) = $_[0];
s/\&/&/g;
s/\</g;
s/\>/>/g;
return $_;
}
# Translate escape sequences back to characters
sub dehtml {
local($_) = $_[0];
s/\<//g;
s/\&/\&/g;
return $_;
}
#
# Main program
#
# Handle -d switch
require 'getopts.pl';
do Getopts('d:');
# Any header stuff in the info file goes to the bit bucket
open(OUT, ">/dev/null");
# Process lines
while (<>) {
# Do this after first <> access so input file can be in original directory
chdir($opt_d), $done_d = 1 if !$done_d && defined($opt_d);
# If we had a *Note that wrapped, tack it onto the beginning of this line
$_ = $leftover . $_;
$leftover = '';
# Start a new node
if (/^\037/) {
# Finish off what we were last doing
if ($menumode) {
print OUT "