Index: HTML.pm =================================================================== --- HTML.pm (revision 6156) +++ HTML.pm (working copy) @@ -7125,8 +7125,82 @@ } } } + + # TODO: Get this from the command-line + my $output_devhelp = 1; + if ($output_devhelp) { + # TODO: What is the name/location of the devhelp file? + # For split v. non-split output + output_devhelp_file ($self, $self->{'output_file'} . '.devhelp', $root); + } } +# Output a .devhelp file usable by GNOME Devhelp. $FILENAME is the name +# the file to write to and $ROOT the root of the parse tree. +sub output_devhelp_file ($$$) +{ + my $self = shift; + my $filename = shift; + my $root = shift; + + print "WRITING DEVHELP $filename\n"; + my $fh = $self->Texinfo::Common::open_out($filename); + if (!$fh) { + $self->document_error(sprintf($self->__( + "could not open %s for writing: %s"), + $filename, $!)); + return; + } + + # Contents of .devhelp file. + my $a = ''; + + # TODO: encoding attribute? + $a .= '' . "\n"; + + $a .= '' . "\n"; + + $a .= '' . "\n"; + foreach my $element (@{$root->{'contents'}}) { + if ($element->{'cmdname'} and $element->{'cmdname'} eq 'chapter') { + my $href = $self->command_href($element); + my $chapter_name = $self->command_text($element); + if ($href and $chapter_name) { + $a .= " \n \n"; + } + } + } + $a .= '' . "\n"; + + my ($index_names, $merged_indices) + = $self->{'parser'}->indices_information(); + if ($index_names and $index_names->{'fn'}) { + + $a .= '' . "\n"; + + foreach my $entry (@{$index_names->{'fn'}->{'index_entries'}}) { + my $command = $entry->{'command'}; + my $href = $self->command_href($command); + my $label = $self->command_text($command); + $a .= "\n"; + } + + $a .= '' . "\n"; + + } + + $a .= '' . "\n"; + + print $fh $a; + $self->register_close_file($filename); + if (!close ($fh)) { + $self->document_error(sprintf($self->__( + "error on closing file %s: %s"), + $filename, $!)); + return undef; + } +} + sub _parse_node_and_warn_external($$$$$) { my $self = shift;