bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

definition styling


From: Gavin Smith
Subject: definition styling
Date: Wed, 3 Mar 2021 22:00:49 +0000
User-agent: Mutt/1.9.4 (2018-02-28)

On Tue, Feb 16, 2021 at 03:46:46PM -0800, Per Bothner wrote:
> * Hide "Script license information" link or move it to "Help" page.
> It's clutter that I don't want on my website, though I might be
> ok with it in the help page.

It could be hidden with CSS as it has the "rel" attribute to identify it,
but if you do this please make sure the link is somewhere the reader can
still find it: probably in the help file.

> * Fix [Function:] in synopsis to remove colon.
> See http://per.bothner.com/tmp/DomTerm-txjs/The-DomTerm-JavaScript-class.html
> [This can probably be done with a DomTerm-specific JavaScript hook.]

Where there is currently

<dl class="def">
<dt id="index-allowAttribute"><span class="category">Function: 
</span><span><strong>allowAttribute</strong> <em>(name, value elementInfo, 
parents)</em><a href='#index-allowAttribute' class='copiable-anchor'> 
&para;</a></span></dt>
<dd><p>Overridable function called by the HTML sanitizer.
</p></dd></dl>

this should be changed to

<dl class="def">
<dt id="index-allowAttribute"><span class="category">Function</span>: <span 
class="prototype"><strong>allowAttribute</strong> <em>(name, value elementInfo, 
parents)</em><a href='#index-allowAttribute' class='copiable-anchor'> 
&para;</a></span></dt>
<dd><p>Overridable function called by the HTML sanitizer.
</p></dd></dl>

i.e. move the ": " string outside of the first span, and give a class
to the second span.  Then (I assume) you could hide the whole of
"dl.def dt", but make an exception for "dl.def dt span.category" and
for "dl.def dt span.prototype" to make that visible.  This would leave
only the ": " as invisible.

I've been trying to make this change and will likely commit the following
change.  I just need to investigate the changes to the test suite results
(most of them are as expected but there are some unexpected changes in
some perverse usages, like index entries inside @copying), and also
add the class on the second span (although that wouldn't be strictly
necessary as you could just make "dt.def dt span" visible).

diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 13d3daf88d..12b89c5fbf 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -4373,15 +4373,8 @@ sub _convert_def_line_type($$$$)
       $name = '';
     }
     my $category = $command->{'extra'}->{'def_parsed_hash'}->{'category'};
-    my $category_result = '';
-    my $category_tree;
-    if ($category) {
-      $category_tree
-        = {'type' => '_code',
-           'contents'=>[$self->gdt("{category}: ", {'category' => $category})]
-          };
-      # NB perhaps the category shouldn't be in_code.
-    } else {
+    my $category_separator = ''; # set if we output the category separately
+    if (!$category) {
       $category = '';
     }
     # no type
@@ -4398,7 +4391,7 @@ sub _convert_def_line_type($$$$)
              or ($command_name eq 'deftypecv'
                  and !$command->{'extra'}->{'def_parsed_hash'}->{'type'}))
             and !$command->{'extra'}->{'def_parsed_hash'}->{'class'})) {
-      $category_result = $self->convert_tree($category_tree);
+      $category_separator = $self->gdt(": ");
       if ($arguments) {
         $tree = $self->gdt("\@strong{{name}} \@emph{{arguments}}", {
                 'name' => $name,
@@ -4418,15 +4411,12 @@ sub _convert_def_line_type($$$$)
                 'type' => $command->{'extra'}->{'def_parsed_hash'}->{'type'},
                 'arguments' => $arguments};
         if ($self->get_conf('deftypefnnewline') eq 'on') {
-          $category_tree
-            = {'type' => '_code',
-               'contents'
-                  => [$self->gdt("{category}:\@* ", {'category' => $category})]
-              };
+          $category_separator = $self->gdt(":\n");
           $tree 
              = $self->gdt("\@emph{{type}}\@* \@strong{{name}} 
\@emph{{arguments}}", 
                           $strings);
         } else {
+          $category_separator = $self->gdt(": ");
           $tree 
              = $self->gdt("\@emph{{type}} \@strong{{name}} 
\@emph{{arguments}}", 
                           $strings);
@@ -4436,17 +4426,13 @@ sub _convert_def_line_type($$$$)
                 'type' => $command->{'extra'}->{'def_parsed_hash'}->{'type'},
                 'name' => $name};
         if ($self->get_conf('deftypefnnewline') eq 'on') {
-          $category_tree
-            = {'type' => '_code',
-               'contents'
-                  => [$self->gdt("{category}:\@* ", {'category' => $category})]
-              };
+          $category_separator = $self->gdt(":\n");
         } else {
+          $category_separator = $self->gdt(": ");
           $tree = $self->gdt("\@emph{{type}} \@strong{{name}}",
                   $strings);
         }
       }
-      $category_result = $self->convert_tree($category_tree);
     # with a class, no type
     } elsif ($command_name eq 'defcv'
              or ($command_name eq 'deftypecv'
@@ -4547,9 +4533,11 @@ sub _convert_def_line_type($$$$)
       }
     }
 
-    if ($category_result ne '') {
-      $category_result = $self->_attribute_class('span', 'category')
-                            .">$category_result</span>";
+    my $category_result = '';
+    if ($category_separator ne '') {
+      $category_result = $self->_attribute_class('span', 'category') . ">"
+        . $self->convert($category) . "</span>"
+        . $self->convert($category_separator);
     }
     my $anchor = $self->_get_copiable_anchor($index_id);
     return "<dt$index_label>".$category_result




reply via email to

[Prev in Thread] Current Thread [Next in Thread]