[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Fri, 16 Feb 2024 17:52:05 -0500 (EST) |
branch: master
commit 7e5ff5394f9dd570e31d6478a9da1e083d7fa8c0
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Feb 16 23:51:57 2024 +0100
* tp/Texinfo/Convert/HTML.pm (%default_shared_conversion_states)
(_convert_listoffloats_command), tp/Texinfo/XS/convert/convert_html.c
(convert_listoffloats_command, html_initialize_output_state)
(html_reset_converter), tp/Texinfo/XS/convert/get_html_perl_info.c
(html_set_shared_conversion_state, html_get_shared_conversion_state),
tp/Texinfo/XS/main/converter_types.h (HTML_SHARED_CONVERSION_STATE),
doc/texi2any_api.texi (Shared Conversion State in Defaut Formatting):
add listoffloats formatted_listoffloats shared state to record the
number of time a listoffloat type was converted.
---
ChangeLog | 12 +++++++
doc/texi2any_api.texi | 3 ++
tp/Texinfo/Convert/HTML.pm | 20 +++++++++---
tp/Texinfo/XS/convert/convert_html.c | 31 +++++++++++++++++-
tp/Texinfo/XS/convert/get_html_perl_info.c | 50 ++++++++++++++++++++++++++++++
tp/Texinfo/XS/main/converter_types.h | 1 +
6 files changed, 111 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 673e5b6a12..8c0780c4be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-02-16 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm (%default_shared_conversion_states)
+ (_convert_listoffloats_command), tp/Texinfo/XS/convert/convert_html.c
+ (convert_listoffloats_command, html_initialize_output_state)
+ (html_reset_converter), tp/Texinfo/XS/convert/get_html_perl_info.c
+ (html_set_shared_conversion_state, html_get_shared_conversion_state),
+ tp/Texinfo/XS/main/converter_types.h (HTML_SHARED_CONVERSION_STATE),
+ doc/texi2any_api.texi (Shared Conversion State in Defaut Formatting):
+ add listoffloats formatted_listoffloats shared state to record the
+ number of time a listoffloat type was converted.
+
2024-02-16 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/HTML.pm (html_convert_css_string),
diff --git a/doc/texi2any_api.texi b/doc/texi2any_api.texi
index 867f1eb50a..439ec4400f 100644
--- a/doc/texi2any_api.texi
+++ b/doc/texi2any_api.texi
@@ -3282,6 +3282,7 @@ default formatting functions:
@item @code{acronym} @tab @code{explained_commands} @tab string (first
argument) @tab string
@item @code{footnote} @tab @code{footnote_number} @tab @tab integer
@item @code{footnote} @tab @code{footnote_id_numbers} @tab string (footnote
id) @tab integer
+@item @code{listoffloats} @tab @code{formatted_listoffloats} @tab string
(normalized argument) @tab integer
@item @code{menu} @tab @code{html_menu_entry_index} @tab @tab integer
@item @code{printindex} @tab @code{formatted_index_entries} @tab index_entry
(index entry hash) @tab integer
@item @code{top} @tab @code{in_skipped_node_top} @tab @tab integer
@@ -3301,6 +3302,8 @@ Associate a footnote identifier, typically used in
hyperlink reference,
to the number of time the corresponding footnote was formatted. More than
one corresponds to very rare cases, for instance a footnote in @code{@@copying}
and multiple @code{@@insertcopying}.
+@item formatted_listoffloats
+Associate a list of float type to the number of time it was formatted.
@item html_menu_entry_index
Current number of menu entries in a menu. Reset to 0 at @code{@@menu}
beginning.
@item formatted_index_entries
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index fc404d7bd8..0945c07af8 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -2007,6 +2007,7 @@ my %default_shared_conversion_states = (
'acronym' => {'explained_commands' => ['string', 'string']},
'footnote' => {'footnote_number' => ['integer'],
'footnote_id_numbers' => ['string', 'integer']},
+ 'listoffloats' => {'formatted_listoffloats' => ['string', 'integer']},
'menu' => {'html_menu_entry_index' => ['integer']},
'printindex' => {'formatted_index_entries' => ['index_entry', 'integer']},
'nodedescription' => {'formatted_nodedescriptions' => ['element',
'integer']},
@@ -3034,8 +3035,6 @@ my %default_commands_args = (
'link' => [['monospace'],['normal'],['filenametext']],
'image' => [['monospacestring', 'filenametext',
'url'],['filenametext'],['filenametext'],['normal','string'],['filenametext']],
# FIXME shouldn't it better not to convert if later ignored?
- # note that right now ignored argument are in elided empty types
- # but this could change.
'inlinefmt' => [['monospacetext'],['normal']],
'inlinefmtifelse' => [['monospacetext'],['normal'],['normal']],
'inlineraw' => [['monospacetext'],['raw']],
@@ -5457,6 +5456,15 @@ sub _convert_listoffloats_command($$$$)
$floats = $document->floats_information();
}
my $listoffloats_name = $command->{'extra'}->{'float_type'};
+ my $formatted_listoffloats_nr
+ = $self->get_shared_conversion_state('listoffloats',
+ 'formatted_listoffloats',
+ $listoffloats_name);
+ $formatted_listoffloats_nr = 0 if (!defined($formatted_listoffloats_nr));
+ $formatted_listoffloats_nr++;
+ $self->set_shared_conversion_state('listoffloats', 'formatted_listoffloats',
+ $listoffloats_name, $formatted_listoffloats_nr);
+
if ($floats and $floats->{$listoffloats_name}
and scalar(@{$floats->{$listoffloats_name}})) {
my $result = $self->html_attribute_class('dl', [$cmdname]).">\n" ;
@@ -5486,10 +5494,12 @@ sub _convert_listoffloats_command($$$$)
my $caption_text;
my @caption_classes;
if ($caption_element) {
- # FIXME 'listoffloats' multiple pass/formatting argument is not
- # unicized.
+ my $multiple_formatted = 'listoffloats';
+ if ($formatted_listoffloats_nr > 1) {
+ $multiple_formatted .= '-'.($formatted_listoffloats_nr - 1);
+ }
$caption_text = $self->convert_tree_new_formatting_context(
- $caption_element->{'args'}->[0], $cmdname, 'listoffloats');
+ $caption_element->{'args'}->[0], $cmdname, $multiple_formatted);
push @caption_classes, "${caption_cmdname}-in-${cmdname}";
} else {
$caption_text = '';
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 630088800a..66b02547f3 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -10930,12 +10930,23 @@ convert_listoffloats_command (CONVERTER *self, const
enum command_id cmd,
if (!strcmp (float_types->type, listoffloats_name))
{
char *attribute_class;
+ char *multiple_pass_str;
STRING_LIST *classes;
size_t j;
+ int *formatted_listoffloats_nr;
if (float_types->float_list.number <= 0)
return;
+ formatted_listoffloats_nr
+ = &self->shared_conversion_state.formatted_listoffloats_nr[i];
+ (*formatted_listoffloats_nr)++;
+ if (*formatted_listoffloats_nr > 1)
+ xasprintf (&multiple_pass_str, "listoffloats-%d",
+ (*formatted_listoffloats_nr) - 1);
+ else
+ multiple_pass_str = "listoffloats";
+
classes = (STRING_LIST *) malloc (sizeof (STRING_LIST));
memset (classes, 0, sizeof (STRING_LIST));
add_string (builtin_command_name (cmd), classes);
@@ -10998,7 +11009,7 @@ convert_listoffloats_command (CONVERTER *self, const
enum command_id cmd,
= convert_tree_new_formatting_context (self,
caption_element->args.list[0],
builtin_command_name (cmd),
- "listoffloats", 0, 0);
+ multiple_pass_str, 0, 0);
text_append (result, caption_text);
free (caption_text);
}
@@ -11006,6 +11017,8 @@ convert_listoffloats_command (CONVERTER *self, const
enum command_id cmd,
}
text_append_n (result, "</dl>\n", 6);
+ if (*formatted_listoffloats_nr > 1)
+ free (multiple_pass_str);
free (attribute_class);
destroy_strings_list (classes);
}
@@ -16606,6 +16619,19 @@ html_initialize_output_state (CONVERTER *self, char
*context)
}
free (sorted_index_names);
}
+
+ if (self->document)
+ {
+ LISTOFFLOATS_TYPE_LIST *listoffloats = self->document->listoffloats;
+
+ if (listoffloats && listoffloats->number)
+ {
+ self->shared_conversion_state.formatted_listoffloats_nr
+ = (int *) malloc (listoffloats->number * sizeof (int));
+ memset (self->shared_conversion_state.formatted_listoffloats_nr,
+ 0, listoffloats->number * sizeof (int));
+ }
+ }
}
void
@@ -16710,6 +16736,9 @@ html_reset_converter (CONVERTER *self)
free (self->shared_conversion_state.footnote_id_numbers);
+ free (self->shared_conversion_state.formatted_listoffloats_nr);
+ self->shared_conversion_state.formatted_listoffloats_nr = 0;
+
if (self->document->index_names)
{
for (i = 0; i < self->sorted_index_names.number; i++)
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index a655fb2413..e99072e7fe 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -1476,6 +1476,32 @@ html_set_shared_conversion_state (CONVERTER *converter,
SV *converter_in,
if (target_info)
target_info->formatted_nodedescription_nr = number;
}
+ else if (!strcmp (state_name, "formatted_listoffloats"))
+ {
+ char *type = (char *)SvPVutf8_nolen(args_sv[0]);
+ int number = SvIV (args_sv[1]);
+ if (converter->document && converter->document->listoffloats)
+ {
+ int i;
+ LISTOFFLOATS_TYPE_LIST
+ *listoffloats = converter->document->listoffloats;
+ for (i = 0; i < listoffloats->number; i++)
+ {
+ LISTOFFLOATS_TYPE *float_types = &listoffloats->float_types[i];
+ if (!strcmp (float_types->type, type))
+ {
+ if (float_types->float_list.number >= 0)
+ {
+ int *formatted_listoffloats_nr
+ = &converter->shared_conversion_state
+ .formatted_listoffloats_nr[i];
+ *formatted_listoffloats_nr = number;
+ }
+ break;
+ }
+ }
+ }
+ }
else if (!strcmp (state_name, "in_skipped_node_top"))
{
int in_skipped_node_top = SvIV (args_sv[0]);
@@ -1538,6 +1564,30 @@ html_get_shared_conversion_state (CONVERTER *converter,
SV *converter_in,
if (target_info && target_info->formatted_nodedescription_nr > 0)
return newSViv (target_info->formatted_nodedescription_nr);
}
+ else if (!strcmp (state_name, "formatted_listoffloats"))
+ {
+ char *type = (char *)SvPVutf8_nolen(args_sv[0]);
+ if (converter->document && converter->document->listoffloats)
+ {
+ int i;
+ LISTOFFLOATS_TYPE_LIST *listoffloats
+ = converter->document->listoffloats;
+ for (i = 0; i < listoffloats->number; i++)
+ {
+ LISTOFFLOATS_TYPE *float_types = &listoffloats->float_types[i];
+ if (!strcmp (float_types->type, type))
+ {
+ if (float_types->float_list.number >= 0)
+ {
+ return newSViv (converter->shared_conversion_state
+ .formatted_listoffloats_nr[i]);
+ }
+ else
+ return newSV (0);
+ }
+ }
+ }
+ }
else if (!strcmp (state_name, "in_skipped_node_top"))
return newSViv(converter->shared_conversion_state.in_skipped_node_top);
return newSV (0);
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index 68fa6b4f6c..38f2baa607 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -313,6 +313,7 @@ typedef struct HTML_SHARED_CONVERSION_STATE {
FOOTNOTE_ID_NUMBER *footnote_id_numbers; /* footnote_id_numbers->{char
$footid} = int */
int html_menu_entry_index;
int **formatted_index_entries; /* formatted_index_entries->{INDEX_ENTRY
$index_entry_ref} = 1, ++ */
+ int *formatted_listoffloats_nr;
/* stored in HTML_TARGET formatted_nodedescription_nr */
/* formatted_nodedescriptions */
} HTML_SHARED_CONVERSION_STATE;