Don't put broken links in HTML info pages
Pass the valid info page names to emp2html.pl, and convert only valid references to links there.
This commit is contained in:
parent
7a730be185
commit
59a199c69d
2 changed files with 19 additions and 9 deletions
2
Make.mk
2
Make.mk
|
@ -293,7 +293,7 @@ info.nr/%: info/%.t
|
||||||
# Pipes in make are a pain. The "test -s" catches obvious errors.
|
# Pipes in make are a pain. The "test -s" catches obvious errors.
|
||||||
|
|
||||||
info.html/%.html: info/%.t
|
info.html/%.html: info/%.t
|
||||||
perl $(srcdir)/info/emp2html.pl $< >$@
|
$(call quiet-command,perl $(srcdir)/info/emp2html.pl $(info) <$< >$@,GEN $@)
|
||||||
|
|
||||||
|
|
||||||
### Explicit rules
|
### Explicit rules
|
||||||
|
|
|
@ -31,9 +31,10 @@
|
||||||
# Drake Diedrich, 1996
|
# Drake Diedrich, 1996
|
||||||
# Markus Armbruster, 2004-2013
|
# Markus Armbruster, 2004-2013
|
||||||
#
|
#
|
||||||
# Usage: emp2html.pl [INFO-FILE]
|
# Usage: emp2html.pl INFO...
|
||||||
#
|
#
|
||||||
# Convert INFO-FILE (or else standard input) to HTML on standard output.
|
# Convert info source on standard input to HTML on standard output.
|
||||||
|
# INFO... are the info page names.
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
@ -43,13 +44,18 @@ my $esc = "\\";
|
||||||
my $ignore = 0;
|
my $ignore = 0;
|
||||||
my $is_subj;
|
my $is_subj;
|
||||||
my @a;
|
my @a;
|
||||||
|
my %topic;
|
||||||
|
|
||||||
|
for (@ARGV) {
|
||||||
|
$topic{$_} = 1;
|
||||||
|
}
|
||||||
|
|
||||||
print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n";
|
print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n";
|
||||||
print " \"http://www.w3.org/TR/html4/strict.dtd\">\n";
|
print " \"http://www.w3.org/TR/html4/strict.dtd\">\n";
|
||||||
print "<html>\n";
|
print "<html>\n";
|
||||||
print "<head>\n";
|
print "<head>\n";
|
||||||
|
|
||||||
line: while (<>) {
|
line: while (<STDIN>) {
|
||||||
chomp; # strip record separator
|
chomp; # strip record separator
|
||||||
s/((^|[^\\])(\\\\)*)\\\".*/$1/g; # strip comments
|
s/((^|[^\\])(\\\\)*)\\\".*/$1/g; # strip comments
|
||||||
|
|
||||||
|
@ -162,8 +168,7 @@ sub checkarg {
|
||||||
|
|
||||||
sub anchor {
|
sub anchor {
|
||||||
local ($_) = @_;
|
local ($_) = @_;
|
||||||
# FIXME don't create dangling links here
|
return $topic{$_} ? "<a href=\"$_.html\">$_</a>" : $_;
|
||||||
return "<a href=\"$_.html\">$_</a>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Translate HTML special characters into escape sequences
|
# Translate HTML special characters into escape sequences
|
||||||
|
@ -182,13 +187,18 @@ sub htmlify {
|
||||||
s/\\e/&\#92;/g; # escape character
|
s/\\e/&\#92;/g; # escape character
|
||||||
# turn quoted strings that look like info names into links
|
# turn quoted strings that look like info names into links
|
||||||
# tacky...
|
# tacky...
|
||||||
|
my $pfx = "";
|
||||||
while (/\\\*Q([A-Za-z0-9\-\.]+)\\\*U|\"info ([A-Za-z0-9\-\.]+)\"/) {
|
while (/\\\*Q([A-Za-z0-9\-\.]+)\\\*U|\"info ([A-Za-z0-9\-\.]+)\"/) {
|
||||||
if (defined $1) {
|
if (defined $1 && $topic{$1}) {
|
||||||
$_ = $` . anchor($1) . "$'";
|
$pfx = $` . anchor($1);
|
||||||
|
} elsif (defined $2 && $topic{$2}) {
|
||||||
|
$pfx = "$`\"info " . anchor($2) . "\"";
|
||||||
} else {
|
} else {
|
||||||
$_ = "$`\"info " . anchor($2) . "\"$'";
|
$pfx .= $` . $&;
|
||||||
}
|
}
|
||||||
|
$_ = "$'";
|
||||||
}
|
}
|
||||||
|
$_ = "$pfx$_";
|
||||||
# tranlate more troff escapes and strings
|
# tranlate more troff escapes and strings
|
||||||
s/\\\*Q/<em>/g;
|
s/\\\*Q/<em>/g;
|
||||||
s/\\\*U/<\/em>/g;
|
s/\\\*U/<\/em>/g;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue