[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Tue, 8 Nov 2022 03:29:25 -0500 (EST) |
branch: master
commit 3e6c9a9e59e879d8ef6d369ead48445db17c8e48
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Oct 31 18:19:52 2022 +0100
* tp/Texinfo/Convert/HTML.pm (_prepare_special_elements): for
special elements order, use a hash with indices to be used to order
the special elements instead of an array. More code, but much easier
to customize/modify.
---
ChangeLog | 7 +++++++
tp/Texinfo/Convert/HTML.pm | 32 ++++++++++++++++++++++++++++----
2 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0629bb31e1..4d4014c6d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-10-31 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm (_prepare_special_elements): for
+ special elements order, use a hash with indices to be used to order
+ the special elements instead of an array. More code, but much easier
+ to customize/modify.
+
2022-10-31 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/HTML.pm: remove 'Top' from %defaults
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index f72ba8b395..9e7beab9de 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -1811,7 +1811,12 @@ my %defaults = (
'Frame' => '_frame',
'Toc_Frame' => '_toc_frame',
},
- 'special_elements_order' => ['footnotes', 'contents', 'shortcontents',
'about'],
+ 'special_elements_order' => {
+ 'contents' => 20,
+ 'shortcontents' => 30,
+ 'footnotes' => 10,
+ 'about' => 40,
+ },
'DOCTYPE' => '<!DOCTYPE html>',
'FRAMESET_DOCTYPE' => '<!DOCTYPE html>',
'DEFAULT_RULE' => '<hr>',
@@ -7640,7 +7645,7 @@ sub _process_css_file($$$)
sub _prepare_css($)
{
my $self = shift;
-
+
return if ($self->get_conf('NO_CSS'));
my @css_import_lines;
@@ -8013,7 +8018,7 @@ sub _html_set_pages_files($$$$$$$$)
} else {
my $node_top;
$node_top = $self->{'labels'}->{'Top'} if ($self->{'labels'});
-
+
my $top_node_filename = $self->top_node_filename($document_name);
my $node_top_tree_unit;
# first determine the top node file name.
@@ -8245,7 +8250,26 @@ sub _prepare_special_elements($$$$)
if (defined($self->get_conf('EXTENSION')));
my $special_elements = [];
- foreach my $special_element_variety (@{$self->{'special_elements_order'}}) {
+ # sort special elements according to their index order from
+ # 'special_elements_order'.
+ # First reverse the hash, using arrays in case some elements are at the
+ # same index, and sort to get alphabetically sorted special element
+ # varieties that are at the same index.
+ my %special_elements_indices;
+ foreach my $special_element_variety
+ (sort(keys(%{$self->{'special_elements_order'}}))) {
+ my $index = $self->{'special_elements_order'}->{$special_element_variety};
+ $special_elements_indices{$index} = []
+ if (not exists ($special_elements_indices{$index}));
+ push @{$special_elements_indices{$index}}, $special_element_variety;
+ }
+ # now sort according to indices
+ my @sorted_elements_varieties;
+ foreach my $index (sort { $a <=> $b } (keys(%special_elements_indices))) {
+ push @sorted_elements_varieties, @{$special_elements_indices{$index}};
+ }
+
+ foreach my $special_element_variety (@sorted_elements_varieties) {
next unless ($do_special{$special_element_variety});
my $element = {'type' => 'special_element',
- [no subject], (continued)
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject],
Patrice Dumas <=
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08