How about this (attached) patch.
I've tried --no-split, --split=node, --split=chapter, and --split=section;
the latter both with and without js-info.
I have not tested @part or @raisesections/@lowersections.
I suspect this approach may be more efficent than that used by the DocBook
back-end. It could probably be modified for the latter by changing:
push(@{$self->{'pending_closes'}}, "</div>\n");
to the appropriate closing tag.
--
--Per Bothner
[email protected] http://per.bothner.com/
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 443b6b4702..4b34aeecf2 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -2419,9 +2419,27 @@ sub _convert_heading_command($$$$$)
return $result;
}
+ my $section = $command->{'extra'}->{'associated_section'};
+ if ($section) {
+ my $level = $section->{'level'};
+ while (@{$self->{'pending_closes'}} > $level) {
+ my $close = pop @{$self->{'pending_closes'}};
+ $result .= $close if ($close);
+ }
+ while (@{$self->{'pending_closes'}} < $level) {
+ push(@{$self->{'pending_closes'}}, "");
+ }
+ }
+ $result .= '<div';
+ if ($section) {
+ $result .= ' class="'.$section->{'cmdname'}.'"';
+ push(@{$self->{'pending_closes'}}, "</div>\n");
+ } else {
+ $result .= ' class="node"';
+ }
my $element_id = $self->command_id($command);
- $result .= "<span id=\"$element_id\"></span>"
- if (defined($element_id) and $element_id ne '');
+ $result .= " id=\"$element_id\""
+ if (defined($element_id) and $element_id ne '');
print STDERR "Process $command "
.Texinfo::Structuring::_print_root_command_texi($command)."\n"
@@ -2433,6 +2451,7 @@ sub _convert_heading_command($$$$$)
and $command->{'parent'}->{'type'} eq 'element') {
$element = $command->{'parent'};
}
+ $result .= ">\n";
if ($element) {
$result .= &{$self->{'format_element_header'}}($self, $cmdname,
$command, $element);
@@ -2514,7 +2533,7 @@ sub _convert_heading_command($$$$$)
eq 'inline')))) {
$result .= _mini_toc($self, $command);
}
-
+ $result .= '</div>' if (! $section);
return $result;
}
@@ -4663,9 +4682,6 @@ sub _convert_element_type($$$$)
if ($element->{'extra'}->{'special_element'}) {
$special_element = $element->{'extra'}->{'special_element'};
my $id = $self->command_id($element);
- if ($id ne '') {
- $result .= "<span id=\"$id\"></span>\n";
- }
if ($self->get_conf('HEADERS')
# first in page
or $self->{'counter_in_file'}->{$element->{'filename'}} == 1) {
@@ -4691,13 +4707,13 @@ sub _convert_element_type($$$$)
if ($special_element_body eq '') {
return '';
}
- $result .= $special_element_body;
+ $result .= $special_element_body . '</div>';
} elsif (!$element->{'element_prev'}) {
$result .= $self->_print_title();
if (!$element->{'element_next'}) {
# only one element
my $foot_text = &{$self->{'format_footnotes_text'}}($self);
- return $result.$content.$foot_text.$self->get_conf('DEFAULT_RULE')."\n";
+ return $result.$content.$foot_text.$self->get_conf('DEFAULT_RULE')."</div>\n";
}
}
$result .= $content unless ($special_element);
@@ -5127,6 +5143,7 @@ sub converter_initialize($)
$self->{'document_context'} = [];
$self->{'multiple_pass'} = [];
+ $self->{'pending_closes'} = [];
$self->_new_document_context('_toplevel_context');
if ($self->get_conf('SPLIT') and $self->get_conf('SPLIT') ne 'chapter'
@@ -6495,9 +6512,13 @@ sub _default_end_file($)
{
my $self = shift;
my $program_text = '';
+ while (@{$self->{'pending_closes'}}) {
+ my $close = pop @{$self->{'pending_closes'}};
+ $program_text .= $close if ($close);
+ }
if ($self->get_conf('PROGRAM_NAME_IN_FOOTER')) {
my $program_string = &{$self->{'format_program_string'}}($self);
- $program_text = "<p><font size=\"-1\">
+ $program_text .= "<p><font size=\"-1\">
$program_string
</font></p>";
}