[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Tue, 1 Oct 2024 17:36:52 -0400 (EDT) |
branch: master
commit 46be874939f0d8651cb9777c3d429c4d3c532da3
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Jul 30 00:17:53 2024 +0200
* tp/maintain/generate_code_convert_data.pl: add
BASE_DEFAULT_CSS_ELEMENT_CLASS_STYLE_NR in main/conversion_data.h.
* tp/Texinfo/XS/convert/convert_html.c (html_css_set_selector_style)
(sort_css_element_class_styles, find_css_selector_style): use a
CSS_SELECTOR_STYLE_LIST pointer as first argument. Update callers.
* tp/Texinfo/XS/convert/convert_html.c (html_attribute_class)
(convert_itemize_command): check that style in selector_style is set.
* tp/Texinfo/XS/convert/convert_html.c
(get_special_list_mark_css_string_no_arg_command): add based on
html_initialize_output_state code. Use in
html_initialize_output_state.
* tp/Texinfo/XS/convert/convert_html.c (html_format_setup)
(default_css_element_class_styles): set
default_css_element_class_styles based on
base_default_css_element_class_styles set in main/conversion_data.c,
add and remove selectors with styles.
* tp/Texinfo/XS/convert/convert_html.c (html_initialize_output_state):
initializeself->css_element_class_styles with
default_css_element_class_styles.
* tp/Texinfo/Convert/HTML.pm (converter_initialize),
tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_initialize_sv),
tp/Texinfo/XS/convert/get_html_perl_info.c
(html_converter_initialize_sv): remove
default_css_element_class_styles argument. Set
default_css_element_class_styles as a variable set to 0 in
html_converter_initialize_sv such that the code can be left but is not
run.
---
ChangeLog | 36 +++++++
tp/Texinfo/Convert/HTML.pm | 3 +-
tp/Texinfo/XS/convert/ConvertXS.xs | 5 +-
tp/Texinfo/XS/convert/convert_html.c | 162 ++++++++++++++++++++++++-----
tp/Texinfo/XS/convert/convert_html.h | 4 +-
tp/Texinfo/XS/convert/get_html_perl_info.c | 7 +-
tp/Texinfo/XS/convert/get_html_perl_info.h | 1 -
tp/Texinfo/XS/main/conversion_data.c | 1 +
tp/Texinfo/XS/main/conversion_data.h | 2 +
tp/maintain/generate_code_convert_data.pl | 7 +-
10 files changed, 195 insertions(+), 33 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b0591f6208..5885a9b0be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,39 @@
+2024-07-29 Patrice Dumas <pertusus@free.fr>
+
+ * tp/maintain/generate_code_convert_data.pl: add
+ BASE_DEFAULT_CSS_ELEMENT_CLASS_STYLE_NR in main/conversion_data.h.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_css_set_selector_style)
+ (sort_css_element_class_styles, find_css_selector_style): use a
+ CSS_SELECTOR_STYLE_LIST pointer as first argument. Update callers.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_attribute_class)
+ (convert_itemize_command): check that style in selector_style is set.
+
+ * tp/Texinfo/XS/convert/convert_html.c
+ (get_special_list_mark_css_string_no_arg_command): add based on
+ html_initialize_output_state code. Use in
+ html_initialize_output_state.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_format_setup)
+ (default_css_element_class_styles): set
+ default_css_element_class_styles based on
+ base_default_css_element_class_styles set in main/conversion_data.c,
+ add and remove selectors with styles.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_initialize_output_state):
+ initializeself->css_element_class_styles with
+ default_css_element_class_styles.
+
+ * tp/Texinfo/Convert/HTML.pm (converter_initialize),
+ tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_initialize_sv),
+ tp/Texinfo/XS/convert/get_html_perl_info.c
+ (html_converter_initialize_sv): remove
+ default_css_element_class_styles argument. Set
+ default_css_element_class_styles as a variable set to 0 in
+ html_converter_initialize_sv such that the code can be left but is not
+ run.
+
2024-07-29 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/Makefile.am (main/conversion_data.c),
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index d8610e71f6..d66cb10e74 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -8740,7 +8740,7 @@ my %special_characters = (
'non_breaking_space' => [$xml_named_entity_nbsp, '00A0'],
);
-sub _XS_html_converter_initialize($$$$$$$$$$$$$$)
+sub _XS_html_converter_initialize($$$$$$$$$$$$$)
{
}
@@ -9132,7 +9132,6 @@ sub converter_initialize($)
\%default_output_units_conversion,
\%defaults_format_special_unit_body_contents,
$customized_upper_case_commands,
- \%default_css_element_class_styles,
\%default_converted_directions_strings
);
delete $self->{'sorted_special_unit_varieties'};
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index adc30ce3b9..ea905f848e 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 *default_css_element_class_styles, SV
*default_converted_ [...]
+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 *default_converted_directions_strings)
void
html_conversion_initialization (SV *converter_in, const char *context, SV
*document_in=0)
@@ -2031,7 +2031,8 @@ html_css_set_selector_style (SV *converter_in, css_info,
SV *css_style_sv)
if (SvOK (css_style_sv))
css_style = (char *)SvPVutf8_nolen (css_style_sv);
- html_css_set_selector_style (self, css_info, css_style);
+ html_css_set_selector_style (&self->css_element_class_styles,
+ css_info, css_style);
}
SV *
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index f9fcac2923..04fba64ce1 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -125,6 +125,9 @@ typedef struct SPECIAL_UNIT_BODY_INTERNAL_CONVERSION {
TEXT *result);
} SPECIAL_UNIT_BODY_INTERNAL_CONVERSION;
+/* in main/conversion_data.c */
+extern const CSS_SELECTOR_STYLE base_default_css_element_class_styles[];
+
const char *count_elements_in_filename_type_names[] = {
"total", "remaining", "current"};
@@ -4528,10 +4531,11 @@ compare_selector_style (const void *a, const void *b)
}
static void
-sort_css_element_class_styles (CONVERTER* self)
+sort_css_element_class_styles (
+ CSS_SELECTOR_STYLE_LIST *css_element_class_styles)
{
- qsort (self->css_element_class_styles.list,
- self->css_element_class_styles.number,
+ qsort (css_element_class_styles->list,
+ css_element_class_styles->number,
sizeof (CSS_SELECTOR_STYLE), compare_selector_style);
}
@@ -4555,11 +4559,12 @@ find_css_selector_style
}
void
-html_css_set_selector_style (CONVERTER* self, const char *css_info,
+html_css_set_selector_style (CSS_SELECTOR_STYLE_LIST *css_element_class_styles,
+ const char *css_info,
const char *css_style)
{
CSS_SELECTOR_STYLE *selector_style
- = find_css_selector_style (&self->css_element_class_styles, css_info);
+ = find_css_selector_style (css_element_class_styles, css_info);
if (selector_style)
{
@@ -4571,7 +4576,7 @@ html_css_set_selector_style (CONVERTER* self, const char
*css_info,
else
{
CSS_SELECTOR_STYLE_LIST *elt_class_styles
- = &self->css_element_class_styles;
+ = css_element_class_styles;
if (elt_class_styles->space <= elt_class_styles->number)
{
elt_class_styles->list = realloc (elt_class_styles->list,
@@ -4588,7 +4593,7 @@ html_css_set_selector_style (CONVERTER* self, const char
*css_info,
elt_class_styles->number++;
- sort_css_element_class_styles (self);
+ sort_css_element_class_styles (css_element_class_styles);
}
}
@@ -4940,7 +4945,7 @@ html_attribute_class (CONVERTER *self, const char
*element,
= find_css_selector_style (&self->css_element_class_styles,
selector);
free (selector);
- if (selector_style)
+ if (selector_style && selector_style->style)
{
if (style_nr)
text_printf (&inline_styles, ";%s", selector_style->style);
@@ -12146,7 +12151,7 @@ convert_itemize_command (CONVERTER *self, const enum
command_id cmd,
selector_style = find_css_selector_style
(&self->css_element_class_styles,
ul_mark_selector);
free (ul_mark_selector);
- if (selector_style)
+ if (selector_style && selector_style->style)
{
add_string (mark_class, classes);
}
@@ -16752,6 +16757,25 @@ COMMAND_ID_LIST no_arg_formatted_cmd;
static char *unicode_entities[BUILTIN_CMD_NUMBER];
+static CSS_SELECTOR_STYLE_LIST default_css_element_class_styles;
+
+static char *
+get_special_list_mark_css_string_no_arg_command (enum command_id cmd)
+{
+ int s;
+ for (s = 0;
+ special_list_mark_css_string_no_arg_command[s].cmd > 0;
+ s++)
+ {
+ if (special_list_mark_css_string_no_arg_command[s].cmd == cmd)
+ {
+ return special_list_mark_css_string_no_arg_command[s].string;
+ break;
+ }
+ }
+ return 0;
+}
+
static void
set_no_arg_commands_formatting (HTML_COMMAND_CONVERSION *spec, char *text)
{
@@ -16768,11 +16792,33 @@ html_format_setup (void)
int default_commands_args_nr
= sizeof (default_commands_args) / sizeof (default_commands_args[0]);
int max_args = MAX_COMMAND_ARGS_NR;
+ CSS_SELECTOR_STYLE *css_selector_style;
+ TEXT css_string_text;
enum command_id indented_format[] = {
CM_example, CM_display, CM_lisp, 0
};
+ initialize_css_selector_style_list (&default_css_element_class_styles,
+ BASE_DEFAULT_CSS_ELEMENT_CLASS_STYLE_NR);
+ for (i = 0; i < BASE_DEFAULT_CSS_ELEMENT_CLASS_STYLE_NR; i++)
+ {
+ CSS_SELECTOR_STYLE *selector_style
+ = &default_css_element_class_styles.list[i];
+ selector_style->selector
+ = base_default_css_element_class_styles[i].selector;
+ selector_style->style
+ = base_default_css_element_class_styles[i].style;
+ }
+ sort_css_element_class_styles (&default_css_element_class_styles);
+
+ css_selector_style
+ = find_css_selector_style (&default_css_element_class_styles,
+ "pre.display-preformatted");
+ html_css_set_selector_style (&default_css_element_class_styles,
+ "pre.format-preformatted",
+ css_selector_style->style);
+
for (i = 0; i < default_commands_args_nr; i++)
{
/* we file the status for specified commands, to distinguish them
@@ -16786,9 +16832,19 @@ html_format_setup (void)
for (i = 0; indented_format[i]; i++)
{
+ char *css_selector;
enum command_id cmd = indented_format[i];
html_commands_data[cmd].flags |= HF_indented_preformatted;
+
+ xasprintf (&css_selector, "div.%s", builtin_command_name (cmd));
+ html_css_set_selector_style (&default_css_element_class_styles,
+ css_selector,
+ "margin-left: 3.2em");
+ free (css_selector);
}
+ /* output as div.example instead */
+ html_css_set_selector_style (&default_css_element_class_styles,
+ "div.lisp", 0);
for (i = 0; small_block_associated_command[i][0]; i++)
{
@@ -16952,6 +17008,54 @@ html_format_setup (void)
fprintf (stderr, "BUG: %s: no css_string\n",
builtin_command_data[cmd].cmdname);
}
+
+ /* w not in css_string, set the corresponding
default_css_element_class_styles
+ especially, which also has none and not w in the class */
+ html_css_set_selector_style (&default_css_element_class_styles,
+ "ul.mark-none", "list-style-type: none");
+
+ text_init (&css_string_text);
+ /* setup default_css_element_class_styles for mark commands based on css
strings */
+ for (i = 0; i < no_arg_formatted_cmd_nr; i++)
+ {
+ enum command_id cmd = no_arg_formatted_cmd.list[i];
+ if (default_no_arg_commands_formatting[cmd][HCC_type_css_string].text
+ && builtin_command_data[cmd].flags & CF_brace)
+ {
+ char *selector;
+ text_append_n (&css_string_text, "list-style-type: ", 17);
+ if (cmd == CM_bullet)
+ text_append_n (&css_string_text, "disc", 4);
+ else
+ {
+ char *css_string;
+ const char *p;
+ char *special_list_mark_command
+ = get_special_list_mark_css_string_no_arg_command (cmd);
+ if (special_list_mark_command)
+ css_string = special_list_mark_command;
+ else
+ css_string
+ = default_no_arg_commands_formatting[cmd][HCC_type_css_string].text;
+ p = after_escaped_characters (css_string);
+ text_append_n (&css_string_text, "\"", 1);
+ if (p && !*p)
+ {
+ text_append_n (&css_string_text, css_string,
+ p - css_string - 1);
+ }
+ else
+ text_append (&css_string_text, css_string);
+ text_append_n (&css_string_text, "\"", 1);
+ }
+ xasprintf (&selector, "ul.mark-%s", builtin_command_name (cmd));
+ html_css_set_selector_style (&default_css_element_class_styles,
+ selector, css_string_text.text);
+ free (selector);
+ text_reset (&css_string_text);
+ }
+ }
+ free (css_string_text.text);
}
static int
@@ -17880,6 +17984,7 @@ html_initialize_output_state (CONVERTER *self, const
char *context)
int nr_dir_str_contexts = TDS_context_string + 1;
enum direction_string_type DS_type;
const char *line_break_element;
+ int css_style_idx = 0;
if (!self->document && self->conf->DEBUG.o.integer > 0)
{
@@ -17982,6 +18087,24 @@ html_initialize_output_state (CONVERTER *self, const
char *context)
output_no_arg_commands_formatting[CM_ASTERISK][HCC_type_normal].text
= (char *)self->line_break_element.string;
+ initialize_css_selector_style_list (&self->css_element_class_styles,
+ default_css_element_class_styles.number);
+ for (i = 0; i < default_css_element_class_styles.number; i++)
+ {
+ CSS_SELECTOR_STYLE *default_selector_style
+ = &default_css_element_class_styles.list[i];
+ if (default_selector_style->style)
+ {
+ CSS_SELECTOR_STYLE *selector_style
+ = &self->css_element_class_styles.list[css_style_idx];
+ selector_style->selector = strdup (default_selector_style->selector);
+ selector_style->style = strdup (default_selector_style->style);
+ css_style_idx++;
+ }
+ else
+ self->css_element_class_styles.number--;
+ }
+
for (i = 0; i < no_arg_formatted_cmd.number; i++)
{
enum command_id cmd = no_arg_formatted_cmd.list[i];
@@ -18016,19 +18139,9 @@ html_initialize_output_state (CONVERTER *self, const
char *context)
&& builtin_command_data[cmd].flags & CF_brace
&& cmd != CM_bullet && cmd != CM_w)
{
- int s;
- int special_list_mark_command = 0;
- for (s = 0;
- special_list_mark_css_string_no_arg_command[s].cmd > 0;
- s++)
- {
- if
(special_list_mark_css_string_no_arg_command[s].cmd
- == cmd)
- {
- special_list_mark_command = 1;
- break;
- }
- }
+ const char *special_list_mark_command
+ = get_special_list_mark_css_string_no_arg_command (cmd);
+
if (!special_list_mark_command)
{
char *selector;
@@ -18037,7 +18150,8 @@ html_initialize_output_state (CONVERTER *self, const
char *context)
builtin_command_name (cmd));
xasprintf (&style, "list-style-type: \"%s\"",
result->text);
- html_css_set_selector_style (self,
+ html_css_set_selector_style (
+ &self->css_element_class_styles,
selector, style);
free (selector);
free (style);
@@ -18119,7 +18233,7 @@ html_initialize_output_state (CONVERTER *self, const
char *context)
}
}
- sort_css_element_class_styles (self);
+ sort_css_element_class_styles (&self->css_element_class_styles);
/* set the htmlxref type split of the document */
self->document_htmlxref_split_type = htmlxref_split_type_mono;
diff --git a/tp/Texinfo/XS/convert/convert_html.h
b/tp/Texinfo/XS/convert/convert_html.h
index 38e51e4309..db157631aa 100644
--- a/tp/Texinfo/XS/convert/convert_html.h
+++ b/tp/Texinfo/XS/convert/convert_html.h
@@ -186,7 +186,9 @@ STRING_LIST *html_get_css_elements_classes (CONVERTER *self,
void html_css_add_info (CONVERTER *self, enum css_info_type type,
const char *css_info);
const STRING_LIST *html_css_get_info (CONVERTER *self, enum css_info_type
type);
-void html_css_set_selector_style (CONVERTER* self, const char *css_info,
+void html_css_set_selector_style (
+ CSS_SELECTOR_STYLE_LIST *css_element_class_styles,
+ const char *css_info,
const char *css_style);
const char *html_css_get_selector_style (CONVERTER* self, const char
*css_info);
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index a04e3d2658..4a9106e0c4 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -136,7 +136,6 @@ html_converter_initialize_sv (SV *converter_sv,
SV *default_output_units_conversion,
SV *default_special_unit_body,
SV *customized_upper_case_commands,
- SV *default_css_element_class_styles,
SV *default_converted_directions_strings
)
{
@@ -180,6 +179,8 @@ html_converter_initialize_sv (SV *converter_sv,
int nr_string_directions;
enum direction_string_type DS_type;
int nr_dir_str_contexts = TDS_context_string +1;
+ /* need to be passed as argument to get from Perl */
+ SV *default_css_element_class_styles = 0;
dTHX;
@@ -192,7 +193,9 @@ html_converter_initialize_sv (SV *converter_sv,
default_css_string_formatting_references_hv
= (HV *)SvRV (default_css_string_formatting_references);
- /* Should always be true */
+ /* to get default_css_element_class_styles from Perl.
+ This code is never run as default_css_element_class_styles is always 0
+ as it is not passed from Perl but determined fully in C */
if (default_css_element_class_styles
&& SvOK (default_css_element_class_styles))
{
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.h
b/tp/Texinfo/XS/convert/get_html_perl_info.h
index 6a264bcbc8..9b213c098b 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.h
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.h
@@ -21,7 +21,6 @@ void html_converter_initialize_sv (SV *converter_sv,
SV *default_output_units_conversion,
SV *default_special_unit_body,
SV *customized_upper_case_commands,
- SV *default_css_element_class_styles,
SV *default_converted_directions_strings
);
diff --git a/tp/Texinfo/XS/main/conversion_data.c
b/tp/Texinfo/XS/main/conversion_data.c
index 50d90dc7ef..9ef582d39d 100644
--- a/tp/Texinfo/XS/main/conversion_data.c
+++ b/tp/Texinfo/XS/main/conversion_data.c
@@ -54,6 +54,7 @@ const CSS_SELECTOR_STYLE
base_default_css_element_class_styles[] = {
changing vertical spacing. */
{"a.copiable-link", "visibility: hidden; text-decoration: none;
line-height: 0em"},
{"span:hover a.copiable-link", "visibility: visible"},
+ {0, 0}
};
const char *special_unit_info_type_names[] = {
diff --git a/tp/Texinfo/XS/main/conversion_data.h
b/tp/Texinfo/XS/main/conversion_data.h
index 6707972af4..97c1201c0d 100644
--- a/tp/Texinfo/XS/main/conversion_data.h
+++ b/tp/Texinfo/XS/main/conversion_data.h
@@ -8,6 +8,8 @@ typedef struct HTML_DEFAULT_DIRECTION_STRING_TRANSLATED {
const char *to_convert;
} HTML_DEFAULT_DIRECTION_STRING_TRANSLATED;
+#define BASE_DEFAULT_CSS_ELEMENT_CLASS_STYLE_NR 39
+
enum special_unit_info_type {
SUI_type_none = -1,
SUI_type_class,
diff --git a/tp/maintain/generate_code_convert_data.pl
b/tp/maintain/generate_code_convert_data.pl
index b8e91db8b0..1dc761df25 100755
--- a/tp/maintain/generate_code_convert_data.pl
+++ b/tp/maintain/generate_code_convert_data.pl
@@ -118,6 +118,7 @@ if ($perl_format) {
print OUT "const CSS_SELECTOR_STYLE base_default_css_element_class_styles[]
= {\n";
}
+my $css_element_class_style_nr = 0;
while (<BDCSS>) {
chomp;
my @data = split (/\|/);
@@ -140,6 +141,7 @@ while (<BDCSS>) {
if (!defined($style) or $style eq '') {
die "$base_default_css_element_class_styles_file: Bad style\n";
}
+ $css_element_class_style_nr++;
if ($perl_format) {
print OUT " '$selector' => '$style',\n";
} else {
@@ -157,6 +159,7 @@ if ($perl_format) {
."}\n\n";
} else {
+ print OUT " {0, 0}\n";
print OUT "};\n\n";
print HDR "/* Automatically generated from $program_name */\n\n";
@@ -167,6 +170,8 @@ if ($perl_format) {
.' const char *to_convert;'."\n"
.'} HTML_DEFAULT_DIRECTION_STRING_TRANSLATED;'."\n\n";
+ print HDR "#define BASE_DEFAULT_CSS_ELEMENT_CLASS_STYLE_NR "
+ ."$css_element_class_style_nr\n\n";
}
@@ -708,7 +713,7 @@ if ($perl_format) {
$name_commands{$command_name} = $command;
}
push @commands_order, $command_name;
- print STDERR "$command\n";
+ #print STDERR "$command\n";
}
if ($C_format) {