On Sun, Aug 14, 2022 at 07:18:45AM -0700, Raymond Toy wrote:
> For a while maxima has been customizing the html file names that makeinfo
> uses. Basically, the file names are of the form maxima_nnn.html or
> maxima_toc.html for the table of contents.
>
> I would like to be able to change this so that the appendices or indices
> don't get a number. Using the original names makeinfo would have used is
> fine. I don't know how to do that, so some help would be appreciated.
A new version, with a proper use of the API for the document_name, with
a version that is an update of the code you shown adapted to the current
API, and the other is a file that does what you want, if I understood
correctly.
--
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 and %reference_file_name_file_nr
# should be reset, using a handler
my $file_nr = -1;
my %reference_file_name_file_nr = ();
sub filename_simple($$$)
{
my $converter = shift;
my $element = shift;
my $filename = shift;
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 (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');
} else {
return $prefix.'_'.$file_nr.'.'.$converter->get_conf('EXTENSION');
}
}
}
texinfo_register_file_id_setting_function('tree_unit_file_name', \&filename_simple);
# 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 $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;
} 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;
}
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;
}
}
}
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');
} else {
return $prefix.'_'.$file_nr.'.'.$converter->get_conf('EXTENSION');
}
}
}
texinfo_register_file_id_setting_function('tree_unit_file_name', \&filename_simple);