[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * doc/texi2any_api.texi (Tree Element Conversion
From: |
Patrice Dumas |
Subject: |
branch master updated: * doc/texi2any_api.texi (Tree Element Conversion Functions), tp/Texinfo/Convert/HTML.pm (_convert) (_convert_index_entry_command_type): use the type of index commands, index_entry_command, to select index commands formatting, instead of a modified command name. Convert with _convert_index_entry_command_type, remove _convert_index_command. |
Date: |
Mon, 06 Mar 2023 14:48:16 -0500 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new c29fa62d11 * doc/texi2any_api.texi (Tree Element Conversion
Functions), tp/Texinfo/Convert/HTML.pm (_convert)
(_convert_index_entry_command_type): use the type of index commands,
index_entry_command, to select index commands formatting, instead of a modified
command name. Convert with _convert_index_entry_command_type, remove
_convert_index_command.
c29fa62d11 is described below
commit c29fa62d11417b76c358f735691d85c04677afb6
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Mar 6 20:48:06 2023 +0100
* doc/texi2any_api.texi (Tree Element Conversion Functions),
tp/Texinfo/Convert/HTML.pm (_convert)
(_convert_index_entry_command_type): use the type of index commands,
index_entry_command, to select index commands formatting, instead of
a modified command name. Convert with
_convert_index_entry_command_type, remove _convert_index_command.
---
ChangeLog | 9 +++++++
doc/texi2any_api.texi | 4 ++++
tp/Texinfo/Convert/HTML.pm | 58 ++++++++++++++++++++++------------------------
3 files changed, 41 insertions(+), 30 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 52281ba7aa..61220dc591 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-03-06 Patrice Dumas <pertusus@free.fr>
+
+ * doc/texi2any_api.texi (Tree Element Conversion Functions),
+ tp/Texinfo/Convert/HTML.pm (_convert)
+ (_convert_index_entry_command_type): use the type of index commands,
+ index_entry_command, to select index commands formatting, instead of
+ a modified command name. Convert with
+ _convert_index_entry_command_type, remove _convert_index_command.
+
2023-03-06 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/parsetexi/api.c (store_additional_info),
diff --git a/doc/texi2any_api.texi b/doc/texi2any_api.texi
index 8e49329bdb..9ff0f94688 100644
--- a/doc/texi2any_api.texi
+++ b/doc/texi2any_api.texi
@@ -2091,6 +2091,10 @@ conversion is usually done after formatting the contents
of the element,
but it may sometime be necessary to have some code run when
the element is first encountered.
+For @@-commands with both a command name and a type, the type is used
+as selector for the formating function for @code{def_line},
+@code{definfoenclose_command} and @code{index_entry_command} types.
+
@node Command Tree Element Opening Functions
@subsection Command Tree Element Opening Functions
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 8be3605697..cca9fdd2a2 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -5458,29 +5458,6 @@ foreach my $command(keys(%ref_commands)) {
$default_commands_conversion{$command} = \&_convert_xref_commands;
}
-# note that $cmdname is always cindex, in particular to make
-# customization possible, the actual @-command could be any index entry
-# @-command.
-sub _convert_index_command($$$$)
-{
- my $self = shift;
- my $cmdname = shift;
- my $command = shift;
- my $args = shift;
-
- my $index_id = $self->command_id($command);
- if (defined($index_id) and $index_id ne ''
- and !$self->in_multi_expanded()
- and !$self->in_string()) {
- my $result = &{$self->formatting_function('format_separate_anchor')}($self,
- $index_id,
'index-entry-id');
- $result .= "\n" unless ($self->in_preformatted());
- return $result;
- }
- return '';
-}
-$default_commands_conversion{'cindex'} = \&_convert_index_command;
-
sub _convert_printindex_command($$$$)
{
my $self = shift;
@@ -6257,6 +6234,29 @@ sub _convert_bracketed_type($$$$) {
$default_types_conversion{'bracketed'} = \&_convert_bracketed_type;
+# use the type and not the index commands names, as they are diverse and
+# can be dynamically added, so it is difficult to use as selector for output
+# formatting. The command name can be obtained here as $element->{'cmdname'}.
+sub _convert_index_entry_command_type($$$$)
+{
+ my $self = shift;
+ my $type = shift;
+ my $element = shift;
+ my $content = shift;
+
+ my $index_id = $self->command_id($element);
+ if (defined($index_id) and $index_id ne ''
+ and !$self->in_multi_expanded()
+ and !$self->in_string()) {
+ my $result = &{$self->formatting_function('format_separate_anchor')}($self,
+ $index_id,
'index-entry-id');
+ $result .= "\n" unless ($self->in_preformatted());
+ return $result;
+ }
+ return '';
+}
+$default_types_conversion{'index_entry_command'} =
\&_convert_index_entry_command_type;
+
sub _convert_definfoenclose_type($$$$) {
my $self = shift;
my $type = shift;
@@ -11479,14 +11479,12 @@ sub _convert($$;$)
# better to consider them as a def_line type, as the whole point of the
# def_line type is to handle the same the def*x and def* line formatting.
if ($element->{'cmdname'}
- and !($element->{'type'} and $element->{'type'} eq 'def_line'
- or $element->{'type'} and $element->{'type'} eq
'definfoenclose_command')) {
+ and !(($element->{'type'} and $element->{'type'} eq 'def_line')
+ or ($element->{'type'}
+ and $element->{'type'} eq 'definfoenclose_command')
+ or ($element->{'type'}
+ and $element->{'type'} eq 'index_entry_command'))) {
my $command_name = $element->{'cmdname'};
- # use the same command name for all the index entry commands
- if ($element->{'extra'} and $element->{'extra'}->{'index_entry'}
- and $element->{'cmdname'} and $element->{'cmdname'} =~ /index$/) {
- $command_name = 'cindex';
- }
if ($root_commands{$command_name}) {
$self->{'current_root_command'} = $element;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * doc/texi2any_api.texi (Tree Element Conversion Functions), tp/Texinfo/Convert/HTML.pm (_convert) (_convert_index_entry_command_type): use the type of index commands, index_entry_command, to select index commands formatting, instead of a modified command name. Convert with _convert_index_entry_command_type, remove _convert_index_command.,
Patrice Dumas <=
- Prev by Date:
branch master updated: * tp/Texinfo/XS/parsetexi/api.c (store_additional_info), tp/Texinfo/XS/parsetexi/extra.c (add_extra_contents_array) (add_extra_index_entry), tp/Texinfo/XS/parsetexi/tree.c (destroy_associated_info), tp/Texinfo/XS/parsetexi/tree_types.h: remove extra_contents_array and extra_index_entry extra types and associated functions, add_extra_contents_array and add_extra_index_entry.
- Next by Date:
branch master updated: * tp/Texinfo/Common.pm (_relate_index_entries_to_table_items_in), tp/Texinfo/Convert/LaTeX.pm (_convert), tp/Texinfo/Convert/Plaintext.pm (_convert): use index_entry_command type instead of extra index_entry when this is more relevant.
- Previous by thread:
branch master updated: * tp/Texinfo/XS/parsetexi/api.c (store_additional_info), tp/Texinfo/XS/parsetexi/extra.c (add_extra_contents_array) (add_extra_index_entry), tp/Texinfo/XS/parsetexi/tree.c (destroy_associated_info), tp/Texinfo/XS/parsetexi/tree_types.h: remove extra_contents_array and extra_index_entry extra types and associated functions, add_extra_contents_array and add_extra_index_entry.
- Next by thread:
branch master updated: * tp/Texinfo/Common.pm (_relate_index_entries_to_table_items_in), tp/Texinfo/Convert/LaTeX.pm (_convert), tp/Texinfo/Convert/Plaintext.pm (_convert): use index_entry_command type instead of extra index_entry when this is more relevant.
- Index(es):