Skip to content

Commit a5d0284

Browse files
author
H. Peter Anvin
committed
doc: improve the HTML index readability
Make the HTML index more like what you would expect an index to look like. Signed-off-by: H. Peter Anvin <[email protected]>
1 parent df24338 commit a5d0284

File tree

2 files changed

+51
-26
lines changed

2 files changed

+51
-26
lines changed

doc/nasmdoc.css

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,24 @@ li.toc1 {
4949
li.toc2 {
5050
padding-top: 0.3em;
5151
}
52-
ul.index {
52+
.index li {
5353
list-style-type: none;
54+
display: flex;
55+
flex-direction: row;
56+
justify-content: space-between;
57+
}
58+
.index .term {
59+
display: inline-block;
60+
text-align: left;
61+
vertical-align: top;
62+
flex: 3 3 0;
63+
}
64+
.index .ref {
65+
width: 30%;
66+
display: inline-block;
67+
text-align: right;
68+
vertical-align: top;
69+
flex: 1 1 0;
5470
}
5571
@media not screen {
5672
ul.navbar {
@@ -148,4 +164,8 @@ ul.index {
148164
ul.navbar a:hover {
149165
background-color: #448;
150166
}
167+
168+
.index li:hover {
169+
background: #eef;
170+
}
151171
}

doc/rdsrc.pl

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -969,9 +969,9 @@ sub write_html {
969969
select TEXT;
970970
&html_preamble(0);
971971
print "<h2 class=\"index\">Index</h2>\n";
972-
print "<ul class=\"index\">\n";
972+
print "<div class=\"index\">\n";
973973
&html_index;
974-
print "</ul>\n</body>\n</html>\n";
974+
print "</div>\n\n</body>\n</html>\n";
975975
select STDOUT;
976976
close TEXT;
977977
}
@@ -982,6 +982,7 @@ sub html_preamble {
982982
print "\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
983983
print "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
984984
print "<head>\n";
985+
print "<meta charset=\"UTF-8\" />\n";
985986
print "<title>", $metadata{'title'}, "</title>\n";
986987
print "<link href=\"nasmdoc.css\" rel=\"stylesheet\" type=\"text/css\" />\n";
987988
print "<link href=\"local.css\" rel=\"stylesheet\" type=\"text/css\" />\n";
@@ -1017,11 +1018,12 @@ sub html_postamble {
10171018
sub html_index {
10181019
my $itag, $a, @ientry, $sep, $w, $wd, $wprev, $line;
10191020

1021+
print "<ul>\n";
1022+
10201023
$chapternode = '';
10211024
foreach $itag (@itags) {
10221025
$ientry = $idxmap{$itag};
1023-
@a = @$ientry;
1024-
push @a, "n :";
1026+
my @a = ('HDterm', @$ientry, 'HDref');
10251027
$sep = 0;
10261028
foreach $node (@nodes) {
10271029
next if !$idxnodes{$node,$itag};
@@ -1032,33 +1034,36 @@ sub html_index {
10321034
# makes it unnecessarily wide
10331035
$nn =~ s/^.*\s+//g; # Remove all but the actual index information
10341036

1035-
push @a, "n ," if $sep;
1036-
push @a, "sp", "x $xn", "n $nn", "xe$xn";
1037+
push @a, 'n ,', 'sp' if $sep;
1038+
push @a, "x $xn", "n $nn", "xe$xn";
10371039
$sep = 1;
10381040
}
1039-
print "<li class=\"index\">\n";
1040-
$line = '';
1041-
do {
1042-
do { $w = &word_html(shift @a) } while $w eq "\001"; # nasty hack
1043-
$wd .= $wprev;
1044-
if ($w eq ' ' || $w eq '' || $w eq undef) {
1045-
if (length ($line . $wd) > 75) {
1046-
$line =~ s/\s*$//; # trim trailing spaces
1047-
print "$line\n";
1048-
$line = '';
1049-
$wd =~ s/^\s*//; # trim leading spaces
1041+
print "<li>\n";
1042+
while (defined($w = shift(@a))) {
1043+
die unless ($w =~ /^HD(.*)$/);
1044+
print "<div class=\"$1\">\n";
1045+
1046+
$line = '';
1047+
while ($w ne '' && $a[0] !~ /^HD/) {
1048+
$w = &word_html(shift @a);
1049+
next if ($w eq "\001"); # Nasty hack
1050+
1051+
if ($w =~ /^\s*$/ && length($line.$w) > 75) {
1052+
$line =~ s/\s*$//; # trim trailing spaces
1053+
print $line, "\n"; $line = '';
1054+
}
1055+
$line .= $w;
10501056
}
1051-
$line .= $wd;
1052-
$wd = '';
1053-
}
1054-
$wprev = $w;
1055-
} while ($w ne '' && $w ne undef);
1056-
if ($line =~ /\S/) {
1057-
$line =~ s/\s*$//; # trim trailing spaces
1058-
print $line, "\n";
1057+
if ($line =~ /\S/) {
1058+
$line =~ s/\s*$//; # trim trailing spaces
1059+
print $line, "\n"; $line = '';
1060+
}
1061+
print "</div>\n";
10591062
}
10601063
print "</li>\n";
10611064
}
1065+
1066+
print "</ul>\n";
10621067
}
10631068

10641069
sub word_html {

0 commit comments

Comments
 (0)