[nasm:master] doc: improve the HTML index readability

nasm-bot for H. Peter Anvin hpa at zytor.com
Wed Nov 9 21:39:03 PST 2022


Commit-ID:  a5d02846346fc379dc7a08c60b797ee055b8a519
Gitweb:     http://repo.or.cz/w/nasm.git?a=commitdiff;h=a5d02846346fc379dc7a08c60b797ee055b8a519
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Wed, 9 Nov 2022 21:37:16 -0800
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Wed, 9 Nov 2022 21:37:16 -0800

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 <hpa at zytor.com>


---
 doc/nasmdoc.css | 22 +++++++++++++++++++++-
 doc/rdsrc.pl    | 55 ++++++++++++++++++++++++++++++-------------------------
 2 files changed, 51 insertions(+), 26 deletions(-)

diff --git a/doc/nasmdoc.css b/doc/nasmdoc.css
index 7926d2b4..49dc3a40 100644
--- a/doc/nasmdoc.css
+++ b/doc/nasmdoc.css
@@ -49,8 +49,24 @@ li.toc1 {
 li.toc2 {
     padding-top: 0.3em;
 }
-ul.index {
+.index li {
     list-style-type: none;
+    display: flex;
+    flex-direction: row;
+    justify-content: space-between;
+}
+.index .term {
+    display: inline-block;
+    text-align: left;
+    vertical-align: top;
+    flex: 3 3 0;
+}
+.index .ref {
+    width: 30%;
+    display: inline-block;
+    text-align: right;
+    vertical-align: top;
+    flex: 1 1 0;
 }
 @media not screen {
     ul.navbar {
@@ -148,4 +164,8 @@ ul.index {
     ul.navbar a:hover {
 	background-color: #448;
     }
+
+    .index li:hover {
+	background: #eef;
+    }
 }
diff --git a/doc/rdsrc.pl b/doc/rdsrc.pl
index 53353862..bde9a1a0 100644
--- a/doc/rdsrc.pl
+++ b/doc/rdsrc.pl
@@ -969,9 +969,9 @@ sub write_html {
   select TEXT;
   &html_preamble(0);
   print "<h2 class=\"index\">Index</h2>\n";
-  print "<ul class=\"index\">\n";
+  print "<div class=\"index\">\n";
   &html_index;
-  print "</ul>\n</body>\n</html>\n";
+  print "</div>\n\n</body>\n</html>\n";
   select STDOUT;
   close TEXT;
 }
@@ -982,6 +982,7 @@ sub html_preamble {
     print "\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
     print "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
     print "<head>\n";
+    print "<meta charset=\"UTF-8\" />\n";
     print "<title>", $metadata{'title'}, "</title>\n";
     print "<link href=\"nasmdoc.css\" rel=\"stylesheet\" type=\"text/css\" />\n";
     print "<link href=\"local.css\" rel=\"stylesheet\" type=\"text/css\" />\n";
@@ -1017,11 +1018,12 @@ sub html_postamble {
 sub html_index {
   my $itag, $a, @ientry, $sep, $w, $wd, $wprev, $line;
 
+  print "<ul>\n";
+
   $chapternode = '';
   foreach $itag (@itags) {
     $ientry = $idxmap{$itag};
-    @a = @$ientry;
-    push @a, "n :";
+    my @a = ('HDterm', @$ientry, 'HDref');
     $sep = 0;
     foreach $node (@nodes) {
 	next if !$idxnodes{$node,$itag};
@@ -1032,33 +1034,36 @@ sub html_index {
 	# makes it unnecessarily wide
 	$nn =~ s/^.*\s+//g;	# Remove all but the actual index information
 
-	push @a, "n ," if $sep;
-	push @a, "sp", "x $xn", "n $nn", "xe$xn";
+	push @a, 'n ,', 'sp' if $sep;
+	push @a, "x $xn", "n $nn", "xe$xn";
 	$sep = 1;
     }
-    print "<li class=\"index\">\n";
-    $line = '';
-    do {
-      do { $w = &word_html(shift @a) } while $w eq "\001"; # nasty hack
-      $wd .= $wprev;
-      if ($w eq ' ' || $w eq '' || $w eq undef) {
-        if (length ($line . $wd) > 75) {
-	  $line =~ s/\s*$//; # trim trailing spaces
-	  print "$line\n";
-	  $line = '';
-	  $wd =~ s/^\s*//; # trim leading spaces
+    print "<li>\n";
+    while (defined($w = shift(@a))) {
+	die unless ($w =~ /^HD(.*)$/);
+	print "<div class=\"$1\">\n";
+
+	$line = '';
+	while ($w ne '' && $a[0] !~ /^HD/) {
+	    $w = &word_html(shift @a);
+	    next if ($w eq "\001"); # Nasty hack
+
+	    if ($w =~ /^\s*$/ && length($line.$w) > 75) {
+		$line =~ s/\s*$//; # trim trailing spaces
+		print $line, "\n"; $line = '';
+	    }
+	    $line .= $w;
 	}
-	$line .= $wd;
-	$wd = '';
-      }
-      $wprev = $w;
-    } while ($w ne '' && $w ne undef);
-    if ($line =~ /\S/) {
-      $line =~ s/\s*$//; # trim trailing spaces
-      print $line, "\n";
+	if ($line =~ /\S/) {
+	    $line =~ s/\s*$//; # trim trailing spaces
+	    print $line, "\n"; $line = '';
+	}
+	print "</div>\n";
     }
     print "</li>\n";
   }
+
+  print "</ul>\n";
 }
 
 sub word_html {


More information about the Nasm-commits mailing list