Skip to content

Commit 2fc88a6

Browse files
committed
make the portions of the generated HTML produced by these styles better
conform to XHTML rules.
1 parent 4ee2ff3 commit 2fc88a6

2 files changed

Lines changed: 87 additions & 73 deletions

File tree

Doc/perl/l2hinit.perl

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ package main;
2626
$AUTO_NAVIGATION = 0;
2727

2828
$BODYTEXT = '';
29-
$CHILDLINE = "\n<p><hr>\n";
29+
$CHILDLINE = "\n<p></p><hr />\n";
3030
$VERBOSITY = 0;
3131

3232
# default # of columns for the indexes
@@ -104,6 +104,7 @@ ($$$)
104104
if ($title) {
105105
if ($title =~ /\<[aA] /) {
106106
$title =~ s/\<[aA] /<a class="sectref" rel="$linktype" /;
107+
$title =~ s/ HREF=/ href=/;
107108
}
108109
else {
109110
$title = "<span class=\"sectref\">$title</span>";
@@ -138,7 +139,7 @@ ($)
138139
}
139140
my $iconserver = ($ICONSERVER eq '.') ? '' : "$ICONSERVER/";
140141
return "<img src='$iconserver$name.$IMAGE_TYPE'\n border='0'"
141-
. " height='32' alt='$text' width='32'>";
142+
. " height='32' alt='$text' width='32' />";
142143
}
143144

144145
sub unlinkify($) {
@@ -157,6 +158,7 @@ ($$$)
157158
$s =~ s/\<tex2html_[a-z_]+_visible_mark\>/$r/;
158159
}
159160
$s =~ s/<[aA] /<a rel="$rel" title="$title" \n /;
161+
$s =~ s/ HREF=/ href=/;
160162
return $s;
161163
}
162164
else {
@@ -202,7 +204,7 @@ sub add_child_links {
202204
my $toc = add_real_child_links(@_);
203205
$toc =~ s|\s*</[aA]>|</a>|g;
204206
$toc =~ s/ NAME=\"tex2html\d+\"\s*href=/ href=/gi;
205-
$toc =~ s|</UL>(\s*<BR>)?|</ul>|gi;
207+
$toc =~ s|</UL>(\s*<BR( /)?>)?|</ul>|gi;
206208
return $toc;
207209
}
208210

@@ -227,13 +229,13 @@ ()
227229
sub top_navigation_panel() {
228230
return "\n"
229231
. make_nav_panel()
230-
. "<br><hr>\n";
232+
. "<br /><hr />\n";
231233
}
232234

233235
sub bot_navigation_panel() {
234-
return "\n<p><hr>\n"
236+
return "\n<p></p><hr />\n"
235237
. make_nav_panel()
236-
. "<hr>\n"
238+
. "<hr />\n"
237239
. get_version_text()
238240
. "\n";
239241
}
@@ -409,8 +411,8 @@ sub do_cmd_tableofcontents {
409411
my($closures, $reopens) = preserve_open_tags();
410412
anchor_label('contents', $CURRENT_FILE, $_); # this is added
411413
$MY_CONTENTS_PAGE = "$CURRENT_FILE";
412-
join('', "<BR>\n\\tableofchildlinks[off]", $closures
413-
, make_section_heading($toc_title, 'H2'), $toc_mark
414+
join('', "<br />\n\\tableofchildlinks[off]", $closures
415+
, make_section_heading($toc_title, 'h2'), $toc_mark
414416
, $reopens, $_);
415417
}
416418
# In addition to the standard stuff, add label to allow named node files.
@@ -420,8 +422,8 @@ sub do_cmd_listoffigures {
420422
$loffile = $CURRENT_FILE;
421423
my($closures, $reopens) = preserve_open_tags();
422424
anchor_label('lof', $CURRENT_FILE, $_); # this is added
423-
join('', "<BR>\n", $closures
424-
, make_section_heading($lof_title, 'H2'), $lof_mark
425+
join('', "<br />\n", $closures
426+
, make_section_heading($lof_title, 'h2'), $lof_mark
425427
, $reopens, $_);
426428
}
427429
# In addition to the standard stuff, add label to allow named node files.
@@ -431,8 +433,8 @@ sub do_cmd_listoftables {
431433
$lotfile = $CURRENT_FILE;
432434
my($closures, $reopens) = preserve_open_tags();
433435
anchor_label('lot', $CURRENT_FILE, $_); # this is added
434-
join('', "<BR>\n", $closures
435-
, make_section_heading($lot_title, 'H2'), $lot_mark
436+
join('', "<br />\n", $closures
437+
, make_section_heading($lot_title, 'h2'), $lot_mark
436438
, $reopens, $_);
437439
}
438440
# In addition to the standard stuff, add label to allow named node files.
@@ -473,7 +475,7 @@ sub do_cmd_textohtmlindex {
473475
my $heading = make_section_heading($idx_title, 'h2') . $idx_mark;
474476
my($pre, $post) = minimize_open_tags($heading);
475477
anchor_label('genindex',$CURRENT_FILE,$_); # this is added
476-
return "<br>\n" . $pre . $_;
478+
return "<br />\n" . $pre . $_;
477479
}
478480

479481
$MODULE_INDEX_FILE = '';
@@ -484,7 +486,7 @@ sub do_cmd_textohtmlmoduleindex {
484486
$TITLE = $idx_module_title;
485487
anchor_label('modindex', $CURRENT_FILE, $_);
486488
$MODULE_INDEX_FILE = "$CURRENT_FILE";
487-
$_ = ('<p>' . make_section_heading($idx_module_title, 'h2')
489+
$_ = ('<p></p>' . make_section_heading($idx_module_title, 'h2')
488490
. $idx_module_mark . $_);
489491
return $_;
490492
}
@@ -624,7 +626,7 @@ ($$)
624626
$title = &purify($title,1);
625627
eval("\$title = ". $default_title ) unless ($title);
626628

627-
# allow user-modification of the <TITLE> tag; thanks Dan Young
629+
# allow user-modification of the <title> tag; thanks Dan Young
628630
if (defined &custom_TITLE_hook) {
629631
$title = &custom_TITLE_hook($title, $toc_sec_title);
630632
}
@@ -640,49 +642,50 @@ ($$)
640642
$MY_PARTIAL_HEADER = join('',
641643
($DOCTYPE ? $DTDcomment : ''),
642644
"<html>\n<head>",
643-
($BASE ? "\n<base href=\"$BASE\">" : ''),
644-
"\n<link rel=\"STYLESHEET\" href=\"$STYLESHEET\" type='text/css'>",
645+
($BASE ? "\n<base href=\"$BASE\" />" : ''),
646+
"\n<link rel=\"STYLESHEET\" href=\"$STYLESHEET\" type='text/css'",
647+
" />",
645648
($FAVORITES_ICON
646-
? ("\n<link rel=\"SHORTCUT ICON\" href=\"" . "$FAVORITES_ICON\">")
649+
? ("\n<link rel=\"SHORTCUT ICON\" href=\"$FAVORITES_ICON\" />")
647650
: ''),
648651
($EXTERNAL_UP_LINK
649652
? ("\n<link rel='start' href='" . $EXTERNAL_UP_LINK
650653
. ($EXTERNAL_UP_TITLE ?
651-
"' title='$EXTERNAL_UP_TITLE'>" : "'>"))
654+
"' title='$EXTERNAL_UP_TITLE' />" : "' />"))
652655
: ''),
653656
"\n<link rel=\"first\" href=\"$FILE.html\"",
654657
($t_title ? " title='$t_title'" : ''),
655-
'>',
658+
' />',
656659
($HAVE_TABLE_OF_CONTENTS
657660
? ("\n<link rel='contents' href='$MY_CONTENTS_PAGE'"
658-
. ' title="Contents">')
661+
. ' title="Contents" />')
659662
: ''),
660663
($HAVE_GENERAL_INDEX
661-
? "\n<link rel='index' href="proxy.php?url=https%3A%2F%2Fgithub.com%2Fxiaolanpython%2Fcpython%2Fcommit%2Fgenindex.html" title='Index'>"
664+
? "\n<link rel='index' href="proxy.php?url=https%3A%2F%2Fgithub.com%2Fxiaolanpython%2Fcpython%2Fcommit%2Fgenindex.html" title='Index' />"
662665
: ''),
663666
# disable for now -- Mozilla doesn't do well with multiple indexes
664667
# ($HAVE_MODULE_INDEX
665-
# ? '<link rel="index" href="proxy.php?url=https%3A%2F%2Fgithub.com%2Fxiaolanpython%2Fcpython%2Fcommit%2Fmodindex.html" title="Module Index">'
666-
# . "\n"
668+
# ? '<link rel="index" href="proxy.php?url=https%3A%2F%2Fgithub.com%2Fxiaolanpython%2Fcpython%2Fcommit%2Fmodindex.html" title="Module Index"'
669+
# . " />\n"
667670
# : ''),
668671
($INFO
669672
# XXX We can do this with the Python tools since the About...
670673
# page always gets copied to about.html, even when we use the
671674
# generated node###.html page names. Won't work with the
672675
# rest of the Python doc tools.
673676
? ("\n<link rel='last' href='about.html'"
674-
. " title='About this document...'>"
677+
. " title='About this document...' />"
675678
. "\n<link rel='help' href='about.html'"
676-
. " title='About this document...'>")
679+
. " title='About this document...' />")
677680
: ''),
678681
$more_links_mark,
679682
"\n",
680683
($CHARSET && $HTML_VERSION ge "2.1"
681684
? ('<meta http-equiv="Content-Type" content="text/html; '
682-
. "charset=$CHARSET\">\n")
685+
. "charset=$CHARSET\" />\n")
683686
: ''),
684687
($AESOP_META_TYPE
685-
? "<meta name='aesop' content='$AESOP_META_TYPE'>\n" : ''));
688+
? "<meta name='aesop' content='$AESOP_META_TYPE' />\n" : ''));
686689
}
687690
if (!$charset && $CHARSET) {
688691
$charset = $CHARSET;
@@ -692,11 +695,20 @@ ($$)
692695
# <meta name='description' ...> element in the document head.
693696
my $metatitle = "$title";
694697
$metatitle =~ s/^\d+(\.\d+)*\s*//;
698+
$metatitle = meta_information($metatitle);
699+
$metatitle =~ s/ NAME=/ name=/g;
700+
$metatitle =~ s/ CONTENT=/ content=/g;
695701

696702
join('',
697703
$MY_PARTIAL_HEADER,
698-
&meta_information($metatitle),
704+
$metatitle,
699705
"<title>", $title, "</title>\n</head>\n<body$body>");
700706
}
701707

708+
sub replace_morelinks {
709+
$more_links =~ s/ REL=/ rel=/g;
710+
$more_links =~ s/ HREF=/ href=/g;
711+
$_ =~ s/$more_links_mark/$more_links/e;
712+
}
713+
702714
1; # This must be the last line

0 commit comments

Comments
 (0)