help-texinfo
[Top][All Lists]
Advanced

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

Re: How to add "Up:" to Texinfo navigation bar?


From: Patrice Dumas
Subject: Re: How to add "Up:" to Texinfo navigation bar?
Date: Wed, 28 Aug 2024 10:13:25 +0200

On Mon, Aug 26, 2024 at 03:09:08PM +0200, Rudolf Adamkovič wrote:
> Hi there!
> 
> I would like to have a Texinfo navigation bar as follows:
> 
>     Up: PARENT-SECTION   [Top] [Contents]

Only with Up, or with Next and Prev too, using section names?

If you want to have section names instead of nodes in navigation bar,
you can already use:
@xrefautomaticsectiontitle on

> I tried to add `[\'Up:', ...]' but that results in:
> 
>     Up:, PARENT-SECTION   [Top][Contents]
> 
> /Note the comma./

Indeed, a comma is added before most 'buttons' except for the first
(exceptions are space and a button formatted as [direction]).  I
realized that the documentation is wrong, it says that the delimiter is
printed after the button, while it is actually printed before the button
unless it is the first button, I will fix that shortly in the
development version.

You can use a function reference to put the PARENT-SECTION without
preceding comma. This also allows to have the a good output if
there is no associated section.  For Up it is not actually possible, but
if you want to do the same with Prev and Next, you'll always have the
Prev: and Next: even if there is no associated direction.  To format a
whole button with leading text, I think that there is no other way than 
defining a function, like:

sub _my_button_direction_section_href {
  my ($self, $direction, $source_command) = @_;

  my $href = $self->from_element_direction($direction, 'href',
                                           undef, undef, $source_command);
  my $section = $self->from_element_direction($direction, 'section');
  $section = '' if (!defined($section));

  my $link;
  if (defined($href) and $href ne '') {
    $link = "<a href=\"${href}\">$section</a>";
  } elsif ($section ne '') {
    $link = $section;
  } else {
    return (undef, 0);
  }
  # here you can use something else than $direction for the leading text
  return ("$direction: $link", 1);
}

Then you can select some directions only:
texinfo_set_from_init_file(
     'SECTION_BUTTONS',
      ['Up', \&_my_button_direction_section_href],
      #['Next', \&_my_button_direction_section_href], 
      #['Prev', \&_my_button_direction_section_href], 
      'Top', 'Contents']);

-- 
Pat



reply via email to

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