[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Thu, 18 Apr 2024 14:53:26 -0400 (EDT) |
branch: master
commit 32d666885c03821f6612dacda31cf1edc9046346
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Apr 17 23:53:11 2024 +0200
* doc/texi2any_api.texi (Other Dynamic Information),
(in_multiple_conversions, _internal_command_text)
(convert_tree_new_formatting_context, _noticed_line_warn)
(_set_multiple_conversions, _unset_multiple_conversions): add an API
to access to multiple_conversions.
* tp/Texinfo/Convert/HTML.pm (%XS_conversion_overrides),
tp/Texinfo/XS/convert/ConvertXS.xs (html_set_multiple_conversions)
(html_unset_multiple_conversions, html_in_multiple_conversions),
tp/Texinfo/XS/convert/build_html_perl_state.c
(build_html_formatting_state), tp/Texinfo/XS/convert/convert_html.c
(convert_tree_new_formatting_context, html_internal_command_text): XS
interface for multiple_conversions. Remove previous interface.
---
ChangeLog | 16 ++++++++++++
doc/texi2any_api.texi | 19 +++++++++++++-
tp/Texinfo/Convert/HTML.pm | 36 ++++++++++++++++++++++-----
tp/Texinfo/XS/convert/ConvertXS.xs | 31 +++++++++++++++++++++++
tp/Texinfo/XS/convert/build_html_perl_state.c | 6 -----
tp/Texinfo/XS/convert/convert_html.c | 6 ++---
tp/Texinfo/XS/main/utils.h | 2 +-
7 files changed, 98 insertions(+), 18 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 77cc974a5b..5adc4bc034 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2024-04-17 Patrice Dumas <pertusus@free.fr>
+
+ * doc/texi2any_api.texi (Other Dynamic Information),
+ (in_multiple_conversions, _internal_command_text)
+ (convert_tree_new_formatting_context, _noticed_line_warn)
+ (_set_multiple_conversions, _unset_multiple_conversions): add an API
+ to access to multiple_conversions.
+
+ * tp/Texinfo/Convert/HTML.pm (%XS_conversion_overrides),
+ tp/Texinfo/XS/convert/ConvertXS.xs (html_set_multiple_conversions)
+ (html_unset_multiple_conversions, html_in_multiple_conversions),
+ tp/Texinfo/XS/convert/build_html_perl_state.c
+ (build_html_formatting_state), tp/Texinfo/XS/convert/convert_html.c
+ (convert_tree_new_formatting_context, html_internal_command_text): XS
+ interface for multiple_conversions. Remove previous interface.
+
2024-04-17 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/HTML.pm (_internal_command_text)
diff --git a/doc/texi2any_api.texi b/doc/texi2any_api.texi
index a87d49464f..027db92b6d 100644
--- a/doc/texi2any_api.texi
+++ b/doc/texi2any_api.texi
@@ -2248,10 +2248,27 @@ Otherwise, returns the command name of the alignment
context.
@end deftypefun
To determine if the conversion is in a context converted multiple times,
-use @code{in_multi_expanded}:
+use @code{in_multiple_conversions}:
+@deftypefun {@var{$multiple_conversion} =}
@var{$converter}->in_multiple_conversions ()
+Return true if the Texinfo tree being converted is converted multiple
+times and the current conversion is not the main conversion.
+
+For example, return true if a node name is converted as part of a direction
+string formating in a navigation panel, which is not the
+main expansion of the @code{@@node}. The main @code{@@node} element
+expansion occurs where the @@-command is located.
+@end deftypefun
+
+To determine if the a mutiple expansion context is set, use
+@code{in_multi_expanded}:
@deftypefun {@var{$multi_expanded_context_information} =}
@var{$converter}->in_multi_expanded ()
Return a string representing the multiple expanded context, or @code{undef} if
not in a multiple expanded context.
+
+A multiple expanded context implies to be in multiple conversions. However,
+it is possible to be in multiple conversions without being in a multiple
+expanded context, as a multiple expanded context needs to be set explicitly,
+and is not always needed.
@end deftypefun
To get the current paragraph and preformatted number, use
@code{paragraph_number}
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 6e29b7e92e..48367540af 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -176,6 +176,10 @@ my %XS_conversion_overrides = (
=> "Texinfo::Convert::ConvertXS::html_set_raw_context",
"Texinfo::Convert::HTML::_unset_raw_context"
=> "Texinfo::Convert::ConvertXS::html_unset_raw_context",
+ "Texinfo::Convert::HTML::_set_multiple_conversions"
+ => "Texinfo::Convert::ConvertXS::html_set_multiple_conversions",
+ "Texinfo::Convert::HTML::_unset_multiple_conversions"
+ => "Texinfo::Convert::ConvertXS::html_unset_multiple_conversions",
"Texinfo::Convert::HTML::_debug_print_html_contexts"
=> "Texinfo::Convert::ConvertXS::html_debug_print_html_contexts",
@@ -200,6 +204,8 @@ my %XS_conversion_overrides = (
=> "Texinfo::Convert::ConvertXS::html_in_verbatim",
"Texinfo::Convert::HTML::in_raw"
=> "Texinfo::Convert::ConvertXS::html_in_raw",
+ "Texinfo::Convert::HTML::in_multiple_conversions"
+ => "Texinfo::Convert::ConvertXS::html_in_multiple_conversions",
"Texinfo::Convert::HTML::paragraph_number"
=> "Texinfo::Convert::ConvertXS::html_paragraph_number",
"Texinfo::Convert::HTML::preformatted_number"
@@ -754,6 +760,12 @@ sub in_raw($)
return $self->{'document_context'}->[-1]->{'raw'};
}
+sub in_multiple_conversions($)
+{
+ my $self = shift;
+ return $self->{'multiple_conversions'};
+}
+
sub paragraph_number($)
{
my $self = shift;
@@ -1393,12 +1405,12 @@ sub _internal_command_text($$$)
$tree_root = $selected_tree;
}
- $self->{'multiple_conversions'}++;
+ $self->_set_multiple_conversions();
_push_referred_command_stack_command($self, $command);
$target->{$type} = $self->_convert($tree_root, $explanation);
_pop_referred_command_stack($self);
- $self->{'multiple_conversions'}--;
+ $self->_unset_multiple_conversions;
$self->_pop_document_context();
return $target->{$type};
@@ -2380,7 +2392,7 @@ sub convert_tree_new_formatting_context($$$;$$$)
my $multiple_pass_str = '';
if ($multiple_pass) {
- $self->{'multiple_conversions'}++;
+ $self->_set_multiple_conversions();
push @{$self->{'multiple_pass'}}, $multiple_pass;
$multiple_pass_str = '|M'
}
@@ -2390,7 +2402,7 @@ sub convert_tree_new_formatting_context($$$;$$$)
my $result = $self->convert_tree($tree, "new_fmt_ctx ${context_string_str}");
if ($multiple_pass) {
- $self->{'multiple_conversions'}--;
+ $self->_unset_multiple_conversions();
pop @{$self->{'multiple_pass'}};
}
@@ -3059,14 +3071,14 @@ foreach my $explained_command
(keys(%explained_commands)) {
= [['normal'], ['normal', 'string']];
}
-# intercept warning and error messages to take 'multiple_conversions' into
+# intercept warning and error messages to take multiple_conversions into
# account
sub _noticed_line_warn($$$)
{
my $self = shift;
my $text = shift;
my $line_nr = shift;
- return if ($self->{'multiple_conversions'});
+ return if ($self->in_multiple_conversions());
$self->converter_line_warn($text, $line_nr);
}
@@ -8355,6 +8367,18 @@ sub _unset_raw_context($)
$self->{'document_context'}->[-1]->{'raw'}--;
}
+sub _set_multiple_conversions($)
+{
+ my $self = shift;
+ $self->{'multiple_conversions'}++;
+}
+
+sub _unset_multiple_conversions($)
+{
+ my $self = shift;
+ $self->{'multiple_conversions'}--;
+}
+
# can be set through Texinfo::Config::texinfo_register_file_id_setting_function
my %customizable_file_id_setting_references;
foreach my $customized_reference ('external_target_split_name',
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 549df3def7..b9949f1a33 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -742,6 +742,26 @@ html_unset_raw_context (SV *converter_in)
if (self)
html_unset_raw_context (self);
+void
+html_set_multiple_conversions (SV *converter_in)
+ PREINIT:
+ CONVERTER *self;
+ CODE:
+ self = get_sv_converter (converter_in,
+ "html_set_multiple_conversions");
+ if (self)
+ self->multiple_conversions++;
+
+void
+html_unset_multiple_conversions (SV *converter_in)
+ PREINIT:
+ CONVERTER *self;
+ CODE:
+ self = get_sv_converter (converter_in,
+ "html_unset_multiple_conversions");
+ if (self)
+ self->multiple_conversions--;
+
SV *
html_debug_print_html_contexts (SV *converter_in)
PREINIT:
@@ -870,6 +890,17 @@ html_in_raw (SV *converter_in)
OUTPUT:
RETVAL
+int
+html_in_multiple_conversions (SV *converter_in)
+ PREINIT:
+ const CONVERTER *self;
+ CODE:
+ self = get_sv_converter (converter_in,
+ "html_in_multiple_conversions");
+ RETVAL = self->multiple_conversions;
+ OUTPUT:
+ RETVAL
+
int
html_paragraph_number (SV *converter_in)
PREINIT:
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.c
b/tp/Texinfo/XS/convert/build_html_perl_state.c
index 47242cd720..e51be03794 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_state.c
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.c
@@ -378,12 +378,6 @@ build_html_formatting_state (CONVERTER *converter,
unsigned long flags)
#define FETCH(key) key##_sv = hv_fetch (hv, #key, strlen (#key), 0);
#define STORE(key, value) hv_store (hv, key, strlen (key), value, 0)
- if (flags & HMSF_multiple_conversions)
- {
- STORE("multiple_conversions",
- newSViv (converter->multiple_conversions));
- }
-
if (flags & HMSF_current_root)
{
if (!converter->current_root_command)
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index cf745276e6..c0d39a9f19 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -2818,7 +2818,7 @@ convert_tree_new_formatting_context (CONVERTER *self,
const ELEMENT *tree,
{
self->multiple_conversions++;
push_string_stack_string (&self->multiple_pass, multiple_pass);
- self->modified_state |= HMSF_multiple_pass | HMSF_multiple_conversions;
+ self->modified_state |= HMSF_multiple_pass;
multiple_pass_str = "|M";
}
@@ -2835,7 +2835,7 @@ convert_tree_new_formatting_context (CONVERTER *self,
const ELEMENT *tree,
{
self->multiple_conversions--;
pop_string_stack (&self->multiple_pass);
- self->modified_state |= HMSF_multiple_pass | HMSF_multiple_conversions;
+ self->modified_state |= HMSF_multiple_pass;
}
free (context_string_str);
@@ -3989,13 +3989,11 @@ html_internal_command_text (CONVERTER *self, const
ELEMENT *command,
self->multiple_conversions++;
push_element_reference_stack_element (&self->referred_command_stack,
command, command->hv);
- self->modified_state |= HMSF_multiple_conversions;
target_info->command_text[type]
= html_convert_tree (self, tree_root, explanation);
free (explanation);
pop_element_reference_stack (&self->referred_command_stack);
self->multiple_conversions--;
- self->modified_state |= HMSF_multiple_conversions;
html_pop_document_context (self);
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index 9f947da641..6271ca07ea 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -112,8 +112,8 @@ enum command_location {
/*
#define HMSF_ 0x0400
#define HMSF_ 0x0800
+#define HMSF_ 0x1000
*/
-#define HMSF_multiple_conversions 0x1000
#define HMSF_multiple_pass 0x2000
#define HMSF_translations 0x4000
/*