[Sort-of combining the tread "html structure revisited" (September last year,
and earlier) with the "understanding the code" aspect of the
"texinfo in Google Summer of Code" thead.]
See https://lists.gnu.org/archive/html/bug-texinfo/2020-09/msg00019.html
for what I'm aiming for.
The attached patch does part of the job: It creates div nodes, and attaches
the 'id' references to the div nodes (rather than to span nodes).
The big problem I have is understanding the "global" structure (as opposed to
making local changes in the code) in that the logical nested sectioning
structure
is not reflected. For that. we'd need to generate a <div class="section">
before processing a section node, and defer the closing </div> until after we'd
processed not only the section node, but also all of its subsections.
Figuring out how to do that correctly is difficult, since one has to understand
both the parse tree structure and the control flow. For example, is the
sectioning structure reflected in the tree, or does it have to be inferred?
There are other problems with my patch (some unneeded elements; "node" div
before "section" div), but those are "local" changes that I assume will be
relatively easy once we have the proper nesting.
I.e. if someone can show me how to generate elements like
<div class="section" id=="xxyy">...</div> so it wraps the entire section
(title, header links, node contents *and* its sub-sections), then
I can probably figure out the rest.
--
--Per Bothner
[email protected] http://per.bothner.com/
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 443b6b4702..7f08be66b4 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -2420,8 +2420,10 @@ sub _convert_heading_command($$$$$)
}
my $element_id = $self->command_id($command);
- $result .= "<span id=\"$element_id\"></span>"
- if (defined($element_id) and $element_id ne '');
+ $result .= '<div class="convert-heading-' . $cmdname . '"';
+ $result .= " id=\"$element_id\""
+ if (defined($element_id) and $element_id ne '');
+ $result .= ">\n";
print STDERR "Process $command "
.Texinfo::Structuring::_print_root_command_texi($command)."\n"
@@ -2515,7 +2517,7 @@ sub _convert_heading_command($$$$$)
$result .= _mini_toc($self, $command);
}
- return $result;
+ return $result . '</div>';
}
foreach my $command (keys(%sectioning_commands), 'node') {
@@ -4657,14 +4659,14 @@ sub _convert_element_type($$$$)
}
}
- my $result = '';
+ my $result = "<div class=\"node\">\n";
my $special_element;
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";
+ $result = "<div class=\"node\" id=\"$id\">\n";
}
if ($self->get_conf('HEADERS')
# first in page
@@ -4691,19 +4693,19 @@ 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);
$result .= &{$self->{'format_element_footer'}}($self, $type,
$element, $content);
- return $result;
+ return $result . "</div>";
}
sub _default_element_footer($$$$)