[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/HTML.pm (converter_initializ
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Convert/HTML.pm (converter_initialize), tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_initialize_sv), tp/Texinfo/XS/convert/convert_html.c (default_code_types) (default_pre_class_types, html_converter_initialize) (html_free_converter), tp/Texinfo/XS/convert/get_html_perl_info.c (html_converter_initialize_sv), tp/Texinfo/XS/main/converter_types.h (TYPE_INTEGER_INFORMATION, PRE_CLASS_TYPE_INFO, CONVERTER): set default_code_types and default_pre_class_types. Add html_custom [...] |
Date: |
Wed, 02 Oct 2024 06:21:04 -0400 |
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 c0244cca4e * tp/Texinfo/Convert/HTML.pm (converter_initialize),
tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_initialize_sv),
tp/Texinfo/XS/convert/convert_html.c (default_code_types)
(default_pre_class_types, html_converter_initialize) (html_free_converter),
tp/Texinfo/XS/convert/get_html_perl_info.c (html_converter_initialize_sv),
tp/Texinfo/XS/main/converter_types.h (TYPE_INTEGER_INFORMATION,
PRE_CLASS_TYPE_INFO, CONVERTER): set default_code_types and
default_pre_class_ty [...]
c0244cca4e is described below
commit c0244cca4e90824fb7cc76bca710bb3f31cd1d12
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Jul 31 12:20:19 2024 +0200
* tp/Texinfo/Convert/HTML.pm (converter_initialize),
tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_initialize_sv),
tp/Texinfo/XS/convert/convert_html.c (default_code_types)
(default_pre_class_types, html_converter_initialize)
(html_free_converter), tp/Texinfo/XS/convert/get_html_perl_info.c
(html_converter_initialize_sv), tp/Texinfo/XS/main/converter_types.h
(TYPE_INTEGER_INFORMATION, PRE_CLASS_TYPE_INFO, CONVERTER): set
default_code_types and default_pre_class_types. Add
html_customized_code_types field to CONVERTER with type
TYPE_INTEGER_INFORMATION and html_customized_pre_class_types field
with type PRE_CLASS_TYPE_INFO. Pass customized_type_formatting from
Perl to those converter fields. Do not get code_types nor
pre_class_types from Perl.
---
ChangeLog | 16 +++++
tp/Texinfo/Convert/HTML.pm | 3 +-
tp/Texinfo/XS/convert/ConvertXS.xs | 3 +-
tp/Texinfo/XS/convert/convert_html.c | 54 ++++++++++++++
tp/Texinfo/XS/convert/get_html_perl_info.c | 111 +++++++++++++++--------------
tp/Texinfo/XS/convert/get_html_perl_info.h | 1 +
tp/Texinfo/XS/main/converter_types.h | 12 ++++
7 files changed, 144 insertions(+), 56 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ee00899460..f9d35b2858 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2024-07-31 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm (converter_initialize),
+ tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_initialize_sv),
+ tp/Texinfo/XS/convert/convert_html.c (default_code_types)
+ (default_pre_class_types, html_converter_initialize)
+ (html_free_converter), tp/Texinfo/XS/convert/get_html_perl_info.c
+ (html_converter_initialize_sv), tp/Texinfo/XS/main/converter_types.h
+ (TYPE_INTEGER_INFORMATION, PRE_CLASS_TYPE_INFO, CONVERTER): set
+ default_code_types and default_pre_class_types. Add
+ html_customized_code_types field to CONVERTER with type
+ TYPE_INTEGER_INFORMATION and html_customized_pre_class_types field
+ with type PRE_CLASS_TYPE_INFO. Pass customized_type_formatting from
+ Perl to those converter fields. Do not get code_types nor
+ pre_class_types from Perl.
+
2024-07-31 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/get_html_perl_info.c
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index f84e13caa6..bf9276fafc 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -8745,7 +8745,7 @@ my %special_characters = (
'non_breaking_space' => [$xml_named_entity_nbsp, '00A0'],
);
-sub _XS_html_converter_initialize($$$$$$$$$$$$$$)
+sub _XS_html_converter_initialize($$$$$$$$$$$$$$$)
{
}
@@ -9128,6 +9128,7 @@ sub converter_initialize($)
\%default_output_units_conversion,
\%defaults_format_special_unit_body_contents,
$customized_upper_case_commands,
+ $customized_type_formatting,
$customized_special_unit_info,
$customized_direction_strings
);
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 67787b63c0..53f041c3a0 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -579,7 +579,7 @@ void
html_format_setup ()
void
-html_converter_initialize_sv (SV *converter_in, SV
*default_formatting_references, SV *default_css_string_formatting_references,
SV *default_commands_open, SV *default_commands_conversion, SV
*default_css_string_commands_conversion, SV *default_types_open, SV
*default_types_conversion, SV *default_css_string_types_conversion, SV
*default_output_units_conversion, SV *default_special_unit_body, SV
*customized_upper_case_commands, SV *customized_special_unit_info, SV
*customized_direction_strings)
+html_converter_initialize_sv (SV *converter_in, SV
*default_formatting_references, SV *default_css_string_formatting_references,
SV *default_commands_open, SV *default_commands_conversion, SV
*default_css_string_commands_conversion, SV *default_types_open, SV
*default_types_conversion, SV *default_css_string_types_conversion, SV
*default_output_units_conversion, SV *default_special_unit_body, SV
*customized_upper_case_commands, SV *customized_type_formatting, SV
*customized_special_unit_ [...]
PREINIT:
CONVERTER *self;
CODE:
@@ -605,6 +605,7 @@ html_converter_initialize_sv (SV *converter_in, SV
*default_formatting_reference
default_output_units_conversion,
default_special_unit_body,
customized_upper_case_commands,
+ customized_type_formatting,
customized_direction_strings);
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 66ec385bfd..dceedd562b 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -128,6 +128,18 @@ typedef struct SPECIAL_UNIT_BODY_INTERNAL_CONVERSION {
/* in main/conversion_data.c */
extern const CSS_SELECTOR_STYLE base_default_css_element_class_styles[];
+/* types that are in code style in the default case. '_code' is not
+ a type that can appear in the tree built from Texinfo code, it is used
+ to format a tree fragment as if it was in a @code @-command. */
+static enum element_type default_code_types[] = {
+ ET__code, 0,
+};
+
+const PRE_CLASS_TYPE_INFO default_pre_class_types[] = {
+ {ET_menu_comment, "menu-comment"},
+ {0, 0}
+};
+
const char *count_elements_in_filename_type_names[] = {
"total", "remaining", "current"};
@@ -17454,6 +17466,37 @@ html_converter_initialize (CONVERTER *self)
}
}
+ for (i = 0; default_code_types[i]; i++)
+ self->code_types[default_code_types[i]] = 1;
+
+ if (self->html_customized_code_types)
+ {
+ for (i = 0; self->html_customized_code_types[i].type; i++)
+ {
+ TYPE_INTEGER_INFORMATION *customized_code
+ = &self->html_customized_code_types[i];
+ self->code_types[customized_code->type] = customized_code->integer;
+ }
+ }
+
+ for (i = 0; default_pre_class_types[i].type; i++)
+ {
+ const PRE_CLASS_TYPE_INFO *pre_class_type = &default_pre_class_types[i];
+ self->pre_class_types[pre_class_type->type]
+ = strdup (pre_class_type->pre_class);
+ }
+
+ if (self->html_customized_pre_class_types)
+ {
+ for (i = 0; self->html_customized_pre_class_types[i].type; i++)
+ {
+ PRE_CLASS_TYPE_INFO *customized_pre_class
+ = &self->html_customized_pre_class_types[i];
+ self->pre_class_types[customized_pre_class->type]
+ = strdup (customized_pre_class->pre_class);
+ }
+ }
+
self->direction_unit_direction_name = (const char **) malloc
((nr_special_units + NON_SPECIAL_DIRECTIONS_NR +1) * sizeof (char *));
memcpy (self->direction_unit_direction_name, html_button_direction_names,
@@ -19677,6 +19720,17 @@ html_free_converter (CONVERTER *self)
free (self->html_customized_upper_case_commands);
self->html_customized_upper_case_commands = 0;
+ free (self->html_customized_code_types);
+ self->html_customized_code_types = 0;
+
+ if (self->html_customized_pre_class_types)
+ {
+ for (i = 0; self->html_customized_pre_class_types[i].type; i++)
+ free (self->html_customized_pre_class_types[i].pre_class);
+ free (self->html_customized_pre_class_types);
+ self->html_customized_pre_class_types = 0;
+ }
+
/* should be freed on exit.
free (no_arg_formatted_cmd.list);
*/
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index 9fc3809fc9..8cf7ebaf52 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -226,6 +226,7 @@ html_converter_initialize_sv (SV *converter_sv,
SV *default_output_units_conversion,
SV *default_special_unit_body,
SV *customized_upper_case_commands,
+ SV *customized_type_formatting,
SV *customized_direction_strings
)
{
@@ -253,8 +254,6 @@ html_converter_initialize_sv (SV *converter_sv,
SV **customized_no_arg_commands_formatting_sv;
SV **output_units_conversion_sv;
SV **file_id_setting_sv;
- SV **code_types_sv;
- SV **pre_class_types_sv;
HV *formatting_function_hv;
HV *commands_open_hv;
HV *commands_conversion_hv;
@@ -355,85 +354,89 @@ html_converter_initialize_sv (SV *converter_sv,
}
}
-#define FETCH(key) key##_sv = hv_fetch (converter_hv, #key, strlen (#key), 0);
- FETCH(code_types)
-
- if (code_types_sv)
+ if (customized_type_formatting && SvOK (customized_type_formatting))
{
I32 hv_number;
I32 i;
+ int code_type_idx = 0;
+ int pre_class_idx = 0;
+ HV *customized_type_formatting_hv
+ = (HV *)SvRV (customized_type_formatting);
- HV *code_types_hv = (HV *)SvRV (*code_types_sv);
+ hv_number = hv_iterinit (customized_type_formatting_hv);
- hv_number = hv_iterinit (code_types_hv);
+ converter->html_customized_code_types
+ = (TYPE_INTEGER_INFORMATION *) malloc ((hv_number + 1)
+ * sizeof (TYPE_INTEGER_INFORMATION));
+ memset (converter->html_customized_code_types, 0,
+ (hv_number + 1) * sizeof (TYPE_INTEGER_INFORMATION));
+
+ converter->html_customized_pre_class_types
+ = (PRE_CLASS_TYPE_INFO *) malloc ((hv_number + 1)
+ * sizeof (PRE_CLASS_TYPE_INFO));
+ memset (converter->html_customized_pre_class_types, 0,
+ (hv_number + 1) * sizeof (PRE_CLASS_TYPE_INFO));
for (i = 0; i < hv_number; i++)
{
- int j;
enum element_type type = ET_NONE;
I32 retlen;
char *type_name;
- SV *code_sv = hv_iternextsv (code_types_hv,
+ SV *spec_sv = hv_iternextsv (customized_type_formatting_hv,
&type_name, &retlen);
- if (SvOK (code_sv))
+ if (SvOK (spec_sv))
{
- int code_value = SvIV (code_sv);
- /* this is not very efficient, but should be done only once
- in the default case. If this is needed more, a qsort/bfind
- could be used, but the overhead could probably only be
- justified if finding the type index happens more often */
- for (j = 1; j < TXI_TREE_TYPES_NUMBER; j++)
- {
- if (!strcmp (type_data[j].name, type_name))
- {
- type = j;
- break;
- }
- }
+ type = find_element_type (type_name);
+
if (type == ET_NONE)
{
- fprintf (stderr, "ERROR: %s: code type not found\n",
+ fprintf (stderr, "ERROR: %s: customized type not found\n",
type_name);
}
else
- converter->code_types[type] = code_value;
- }
- }
- }
-
- FETCH(pre_class_types)
-
- if (pre_class_types_sv)
- {
- I32 hv_number;
- I32 i;
+ {
+ HV *spec_hv = (HV *)SvRV (spec_sv);
+ SV **code_sv = hv_fetch (spec_hv, "code",
+ strlen("code"), 0);
+ SV **pre_class_sv = hv_fetch (spec_hv, "pre_class",
+ strlen("pre_class"), 0);
- HV *pre_class_types_hv = (HV *)SvRV (*pre_class_types_sv);
+ if (code_sv)
+ {
+ TYPE_INTEGER_INFORMATION *customized_code
+ =
&converter->html_customized_code_types[code_type_idx];
+ int code_value = 0;
- hv_number = hv_iterinit (pre_class_types_hv);
+ if (SvOK (*code_sv))
+ code_value = SvIV (*code_sv);
- for (i = 0; i < hv_number; i++)
- {
- I32 retlen;
- char *type_name;
- SV *pre_class_sv = hv_iternextsv (pre_class_types_hv,
- &type_name, &retlen);
- if (SvOK (pre_class_sv))
- {
- const char *pre_class = SvPV_nolen (pre_class_sv);
- enum element_type type = find_element_type (type_name);
+ customized_code->type = type;
+ customized_code->integer = code_value;
+ code_type_idx++;
+ }
+ if (pre_class_sv)
+ {
+ PRE_CLASS_TYPE_INFO *customized_pre_class
+ = &converter->html_customized_pre_class_types
+ [pre_class_idx];
+ char *pre_class_value = 0;
- if (type == ET_NONE)
- {
- fprintf (stderr, "ERROR: %s: pre class type not found\n",
- type_name);
+ if (SvOK (*pre_class_sv))
+ {
+ const char *pre_class_string
+ = SvPV_nolen (*pre_class_sv);
+ pre_class_value = non_perl_strdup (pre_class_string);
+ }
+ customized_pre_class->type = type;
+ customized_pre_class->pre_class = pre_class_value;
+ pre_class_idx++;
+ }
}
- else
- converter->pre_class_types[type] = non_perl_strdup (pre_class);
}
}
}
+#define FETCH(key) key##_sv = hv_fetch (converter_hv, #key, strlen (#key), 0);
FETCH(accent_entities)
if (accent_entities_sv)
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.h
b/tp/Texinfo/XS/convert/get_html_perl_info.h
index 42c04e5e35..f73c15a9cd 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.h
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.h
@@ -23,6 +23,7 @@ void html_converter_initialize_sv (SV *converter_sv,
SV *default_output_units_conversion,
SV *default_special_unit_body,
SV *customized_upper_case_commands,
+ SV *customized_type_formatting,
SV *customized_direction_strings
);
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index db0d55fab8..a3597f9678 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -395,6 +395,11 @@ typedef struct COMMAND_INTEGER_INFORMATION {
int integer;
} COMMAND_INTEGER_INFORMATION;
+typedef struct TYPE_INTEGER_INFORMATION {
+ enum element_type type;
+ int integer;
+} TYPE_INTEGER_INFORMATION;
+
typedef struct FILE_NAME_PATH_COUNTER {
char *filename;
char *normalized_filename;
@@ -732,6 +737,11 @@ typedef struct SPECIAL_UNIT_INFO_LIST {
SPECIAL_UNIT_INFO *list;
} SPECIAL_UNIT_INFO_LIST;
+typedef struct PRE_CLASS_TYPE_INFO {
+ enum element_type type;
+ char *pre_class;
+} PRE_CLASS_TYPE_INFO;
+
typedef struct CONVERTER {
int converter_descriptor;
/* perl converter. This should be HV *hv,
@@ -772,6 +782,7 @@ typedef struct CONVERTER {
COMMAND_ID_LIST accent_cmd;
int code_types[TXI_TREE_TYPES_NUMBER];
COMMAND_INTEGER_INFORMATION *html_customized_upper_case_commands;
+ TYPE_INTEGER_INFORMATION *html_customized_code_types;
char *pre_class_types[TXI_TREE_TYPES_NUMBER];
ACCENT_ENTITY_INFO accent_entities[BUILTIN_CMD_NUMBER];
FIXED_STRING_WITH_LEN special_character[SC_non_breaking_space+1];
@@ -815,6 +826,7 @@ typedef struct CONVERTER {
HTML_STAGE_HANDLER_INFO_LIST html_stage_handlers[HSHT_type_finish +1];
HTML_NO_ARG_COMMAND_CONVERSION
*customized_no_arg_commands_formatting[BUILTIN_CMD_NUMBER][NO_ARG_COMMAND_CONTEXT_NR];
char ***customized_directions_strings[(TDS_TYPE_MAX_NR) -
(TDS_TRANSLATED_MAX_NR)];
+ PRE_CLASS_TYPE_INFO *html_customized_pre_class_types;
HTML_STYLE_COMMAND_CONVERSION
html_style_command_conversion[BUILTIN_CMD_NUMBER][STYLE_COMMAND_CONTEXT_NR];
/* set for a converter, modified in a document */
HTML_NO_ARG_COMMAND_CONVERSION
html_no_arg_command_conversion[BUILTIN_CMD_NUMBER][NO_ARG_COMMAND_CONTEXT_NR];
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/HTML.pm (converter_initialize), tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_initialize_sv), tp/Texinfo/XS/convert/convert_html.c (default_code_types) (default_pre_class_types, html_converter_initialize) (html_free_converter), tp/Texinfo/XS/convert/get_html_perl_info.c (html_converter_initialize_sv), tp/Texinfo/XS/main/converter_types.h (TYPE_INTEGER_INFORMATION, PRE_CLASS_TYPE_INFO, CONVERTER): set default_code_types and default_pre_class_types. Add html_custom [...],
Patrice Dumas <=