# 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);