help-texinfo
[Top][All Lists]
Advanced

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

Re: Customizing html file names


From: Patrice Dumas
Subject: Re: Customizing html file names
Date: Wed, 19 Oct 2022 16:04:00 +0200

Hello,

A new version, no functional change, but code could be more clear
like that.

On Mon, Oct 10, 2022 at 09:40:34AM +0200, Patrice Dumas wrote:
> Hello,
> 
> The API changed again, for the new API, the attached init file should be
> ok.
> 
> -- 
> Pat

> # Make the output file names consist of the base name followed by a number.
> use strict;
> 
> # REMARK: if more than one manual is processed, $file_nr, 
> %reference_file_name_file_nr
> # and $after_appendix_printindex should be reset, using a handler
> 
> my $file_nr = -1;
> 
> my %reference_file_name_file_nr = ();
> 
> my $after_appendix_printindex = 0;
> 
> sub filename_simple($$$$)
> {
>   my $converter = shift;
>   my $element = shift;
>   my $filename = shift;
>   my $filepath = shift;
> 
>   return ($filename, $filepath) if (defined($filepath));
> 
>   my $prefix = $converter->get_info('document_name');
>   # If we're not splitting, just return the name.
>   if (!$converter->get_conf('SPLIT')) {
>     return $prefix.'.'.$converter->get_conf('EXTENSION');
>   }
>   if ($converter->element_is_tree_unit_top($element)) {
>     # The table of contents file should be named this.
>     return "maxima_toc.html";
>   } else {
>     if ($after_appendix_printindex) {
>       return ($filename, undef);
>     } else {
>       # FIXME would be more efficient to set it up in a handler (probably 
> 'init')
>       # once for all
>       my $printindex_element = $converter->global_direction_element('Index');
>       if (defined($printindex_element) and $printindex_element eq $element) {
>         $after_appendix_printindex = 1;
>         return ($filename, undef);
>       }
>       if ($element->{'extra'} and $element->{'extra'}->{'unit_command'}) {
>         my $associated_command_element = 
> $element->{'extra'}->{'unit_command'};
>         my $sectioning_command;
>         if ($associated_command_element->{'cmdname'} eq 'node') {
>           if ($associated_command_element->{'extra'}
>               and 
> $associated_command_element->{'extra'}->{'associated_section'}) {
>             $sectioning_command
>               = 
> $associated_command_element->{'extra'}->{'associated_section'}->{'cmdname'};
>           }
>         } else {
>           $sectioning_command = $associated_command_element->{'cmdname'};
>         }
>         if (defined($sectioning_command) and $sectioning_command =~ 
> /appendix/) {
>           $after_appendix_printindex = 1;
>           return ($filename, undef);
>         }
>       }
>     }
>     if (defined($reference_file_name_file_nr{$filename})) {
>       $file_nr = $reference_file_name_file_nr{$filename};
>     } else {
>       $file_nr++;
>       $reference_file_name_file_nr{$filename} = $file_nr;
>     }
>     if ($file_nr == 0) {
>       return ($prefix.'.'.$converter->get_conf('EXTENSION'), undef);
>     } else {
>       return ($prefix.'_'.$file_nr.'.'.$converter->get_conf('EXTENSION'), 
> undef);
>     }
>   }
> }
> 
> texinfo_register_file_id_setting_function('tree_unit_file_name', 
> \&filename_simple);

Attachment: maxima_file_names.pm
Description: Text Data


reply via email to

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