bug-texinfo
[Top][All Lists]
Advanced

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

Re: definition styling


From: Patrice Dumas
Subject: Re: definition styling
Date: Thu, 4 Mar 2021 18:03:17 +0100

On Wed, Mar 03, 2021 at 10:00:49PM +0000, Gavin Smith wrote:
> 
> 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).

I am not very knowledgable on that, but I fear that splitting the :
would make translating quite difficult.  Another option could be to use
markup to remove the need for a :.

> 
> 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]