[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sat, 17 Feb 2024 17:23:47 -0500 (EST) |
branch: master
commit 5f17d10b9bf60e07196c4f0e4f3b0719adff627a
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Feb 17 22:26:10 2024 +0100
* tp/Texinfo/Convert/HTML.pm (_contents_inline_element),
tp/Texinfo/XS/convert/convert_html.c (contents_inline_element):
remove code that was different before when called as convert, but
should be the same now.
* tp/Texinfo/XS/convert/convert_html.c: add const for command_id
return variables when possible.
---
ChangeLog | 10 +++++++
tp/Texinfo/Convert/HTML.pm | 38 ++++++++++-----------------
tp/Texinfo/XS/convert/convert_html.c | 51 ++++++++++++++----------------------
3 files changed, 43 insertions(+), 56 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ee628d9b6c..3c8e460cd7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-02-17 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm (_contents_inline_element),
+ tp/Texinfo/XS/convert/convert_html.c (contents_inline_element):
+ remove code that was different before when called as convert, but
+ should be the same now.
+
+ * tp/Texinfo/XS/convert/convert_html.c: add const for command_id
+ return variables when possible.
+
2024-02-17 Patrice Dumas <pertusus@free.fr>
* doc/texi2any_api.texi (Texinfo Tree Conversion Functions),
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index c63b5642c6..6b8d2ea342 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -4478,8 +4478,8 @@ sub _default_format_button($$;$)
}
$need_delimiter = 0;
}
- # FIXME chose another option among those proposed in comments below?
if (not defined($need_delimiter)) {
+ # NOTE other options could have been chosen in that case:
# option 1: be forgiving if $need_delimiter is not set
# if ($html_default_node_directions{$button}) {
# $need_delimiter = 1;
@@ -4504,7 +4504,7 @@ sub _default_format_navigation_panel($$$$;$)
my $source_command = shift;
my $vertical = shift;
- # do the buttons first in case they are formatteed as an empty string
+ # do the buttons first in case they are formatted as an empty string
my $nr_of_buttons_shown = 0;
my $result_buttons = '';
foreach my $button (@$buttons) {
@@ -4530,7 +4530,7 @@ sub _default_format_navigation_panel($$$$;$)
$source_command);
if ($self->get_conf('HEADER_IN_TABLE')) {
$result_buttons .= '<tr>'."\n" if $vertical;
- $result_buttons .= '<td>';
+ $result_buttons .= '<td>';
if (defined($active)) {
$result_buttons .= $active;
@@ -4554,9 +4554,9 @@ sub _default_format_navigation_panel($$$$;$)
my $result = '';
- # if VERTICAL_HEAD_NAVIGATION, the buttons are in a vertical table which
- # is itself in the first column of a table opened in header_navigation
- #my $vertical = $self->get_conf('VERTICAL_HEAD_NAVIGATION');
+ # if $vertical/VERTICAL_HEAD_NAVIGATION, the buttons are in a vertical
+ # table which is itself in the first column of a table opened in
+ # header_navigation
if ($self->get_conf('HEADER_IN_TABLE')) {
$result .= $self->html_attribute_class('table', ['nav-panel'])
@@ -4733,23 +4733,12 @@ sub _contents_inline_element($$$)
= $self->command_name_special_unit_information($cmdname);
# FIXME is element- the best prefix?
my $result = $self->html_attribute_class('div', ["element-${class_base}"]);
- my $heading;
- if ($special_unit) {
- my $unit_command = $special_unit->{'unit_command'};
- my $id = $self->command_id($unit_command);
- if (defined($id) and $id ne '') {
- $result .= " id=\"$id\"";
- }
- $heading = $self->command_text($unit_command);
- } else {
- # happens when called as convert() and not output()
- my $heading_tree = $self->special_unit_info('heading_tree',
- $special_unit_variety);
- if (defined($heading_tree)) {
- $heading = $self->convert_tree($heading_tree,
- "convert $cmdname special heading");
- }
+ my $unit_command = $special_unit->{'unit_command'};
+ my $id = $self->command_id($unit_command);
+ if (defined($id) and $id ne '') {
+ $result .= " id=\"$id\"";
}
+ my $heading = $self->command_text($unit_command);
$heading = '' if (!defined($heading));
$result .= ">\n";
$result .= &{$self->formatting_function('format_heading_text')}($self,
@@ -7986,8 +7975,9 @@ $default_output_units_conversion{'special_unit'}
= \&_convert_special_unit_type;
# Function for converting the output units. The node and associated section
-# appear together in the output unit. $ELEMENT was created in this module (in
-# _prepare_conversion_units), it's not a tree element (created by the parser).
+# appear together in the output unit. $OUTPUT_UNIT was created in this
+# module (in _prepare_conversion_units), it's not a tree element (created
+# by the parser).
# $CONTENT is the contents of the output unit, already converted.
sub _convert_unit_type($$$$)
{
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index b751df09ce..b9a7ca2b56 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -4168,7 +4168,9 @@ from_element_direction (CONVERTER *self, int direction,
else if (type == HTT_target)
{
if (command)
- return html_command_id (self, command);
+ {
+ return html_command_id (self, command);
+ }
else
return 0;
}
@@ -8803,7 +8805,7 @@ convert_anchor_command (CONVERTER *self, const enum
command_id cmd,
{
if (!html_in_multi_expanded (self) && !html_in_string (self))
{
- char *id = html_command_id (self, element);
+ const char *id = html_command_id (self, element);
if (id && strlen (id))
{
format_separate_anchor (self, id, "anchor", result);
@@ -9690,6 +9692,7 @@ contents_inline_element (CONVERTER *self, const enum
command_id cmd,
= self->command_special_variety_name_index[j];
if (cmd_variety_index.cmd == cmd)
{
+ const char *id;
char *heading = 0;
TEXT result;
STRING_LIST *classes;
@@ -9704,6 +9707,7 @@ contents_inline_element (CONVERTER *self, const enum
command_id cmd,
special_unit_variety);
const OUTPUT_UNIT *special_unit
= self->global_units_directions[special_unit_direction_index];
+ const ELEMENT *unit_command = special_unit->unit_command;
text_init (&result);
@@ -9722,28 +9726,11 @@ contents_inline_element (CONVERTER *self, const enum
command_id cmd,
text_append (&result, attribute_class);
free (attribute_class);
- if (special_unit)
- {
- ELEMENT *unit_command = special_unit->unit_command;
- char *id = html_command_id (self, unit_command);
- if (id && strlen (id))
- text_printf (&result, " id=\"%s\"", id);
- heading = html_command_text (self, unit_command, 0);
- }
- else
- { /* happens when called as convert() and not output() */
- ELEMENT *heading_tree = special_unit_info_tree (self,
- SUIT_type_heading, special_unit_variety);
- if (heading_tree)
- {
- char *explanation;
- xasprintf (&explanation, "convert %s special heading",
- builtin_command_name (cmd));
- heading = html_convert_tree (self, heading_tree,
- explanation);
- free (explanation);
- }
- }
+ id = html_command_id (self, unit_command);
+ if (id && strlen (id))
+ text_printf (&result, " id=\"%s\"", id);
+ heading = html_command_text (self, unit_command, 0);
+
text_append_n (&result, ">\n", 2);
xasprintf (&class, "%s-heading", class_base);
@@ -9857,7 +9844,7 @@ convert_heading_command (CONVERTER *self, const enum
command_id cmd,
const HTML_ARGS_FORMATTED *args_formatted,
const char *content, TEXT *result)
{
- char *element_id;
+ const char *element_id;
OUTPUT_UNIT *output_unit = 0;
TEXT element_header;
/* could use only one, but this is more similar to perl code */
@@ -9868,7 +9855,7 @@ convert_heading_command (CONVERTER *self, const enum
command_id cmd,
char *heading;
int heading_level = -1;
int do_heading;
- char *heading_id = 0;
+ const char *heading_id = 0;
char *level_set_class = 0;
const ELEMENT *opening_section = 0;
@@ -11088,7 +11075,7 @@ convert_float_command (CONVERTER *self, const enum
command_id cmd,
char *attribute_class;
STRING_LIST *classes;
- char *id;
+ const char *id;
char *prepended_text = 0;
char *caption_text = 0;
char *caption_command_name = 0;
@@ -11750,7 +11737,7 @@ convert_item_command (CONVERTER *self, const enum
command_id cmd,
ELEMENT *converted_e;
TREE_ADDED_ELEMENTS *tree;
char *anchor = 0;
- char *index_entry_id;
+ const char *index_entry_id;
char *pre_class_close = 0;
if (cmd != CM_item)
@@ -12473,7 +12460,7 @@ convert_printindex_command (CONVERTER *self, const enum
command_id cmd,
const char *index_name;
INDEX_SORTED_BY_LETTER *idx;
INDEX_SORTED_BY_LETTER *index_sorted = 0;
- char *index_element_id;
+ const char *index_element_id;
char **letter_id;
char **alpha;
char **non_alpha;
@@ -14035,7 +14022,7 @@ convert_index_entry_command_type (CONVERTER *self,
const enum element_type type,
const ELEMENT *element, const char *content,
TEXT *result)
{
- char *index_id;
+ const char *index_id;
if (html_in_string (self) || html_in_multi_expanded (self))
return;
@@ -14717,7 +14704,7 @@ convert_def_line_type (CONVERTER *self, const enum
element_type type,
const ELEMENT *element, const char *content,
TEXT *result)
{
- char *index_id;
+ const char *index_id;
PARSED_DEF *parsed_def;
STRING_LIST *classes;
char *attribute_class;
@@ -15208,7 +15195,7 @@ convert_special_unit_type (CONVERTER *self,
size_t number;
TEXT special_unit_body;
ELEMENT *unit_command;
- char *id;
+ const char *id;
char *class_base;
char *attribute_class;
char *class;