[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/convert/convert_html.c (convert_n
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/convert/convert_html.c (convert_no_arg_command) (text_element_conversion, html_converter_initialize): implement convert_no_arg_command. |
Date: |
Fri, 08 Dec 2023 14:31:31 -0500 |
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 f2c816edd8 * tp/Texinfo/XS/convert/convert_html.c
(convert_no_arg_command) (text_element_conversion, html_converter_initialize):
implement convert_no_arg_command.
f2c816edd8 is described below
commit f2c816edd84e3f3aaa724902862cbd9a848374df
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Dec 8 20:31:19 2023 +0100
* tp/Texinfo/XS/convert/convert_html.c (convert_no_arg_command)
(text_element_conversion, html_converter_initialize): implement
convert_no_arg_command.
---
ChangeLog | 6 ++
tp/Texinfo/XS/convert/convert_html.c | 113 +++++++++++++++++++++++++++++++++++
2 files changed, 119 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 5ed18493d2..ab5dfc89b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-12-08 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/convert_html.c (convert_no_arg_command)
+ (text_element_conversion, html_converter_initialize): implement
+ convert_no_arg_command.
+
2023-12-08 Patrice Dumas <pertusus@free.fr>
* tp/t/test_utils.pl (convert_to_html): get XS error messages by
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index e46633af3c..eb0a838423 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -5925,6 +5925,101 @@ convert_row_type (CONVERTER *self, const enum
element_type type,
}
}
+static void
+text_element_conversion (CONVERTER *self,
+ const HTML_COMMAND_CONVERSION *specification,
+ const enum command_id cmd,
+ TEXT *result)
+{
+ if (specification->element)
+ {
+ STRING_LIST *classes;
+ char *attribute_class;
+ classes = (STRING_LIST *) malloc (sizeof (STRING_LIST));
+ memset (classes, 0, sizeof (STRING_LIST));
+ add_string (builtin_command_name (cmd), classes);
+
+ attribute_class
+ = html_attribute_class (self, specification->element, classes);
+ destroy_strings_list (classes);
+ text_append (result, attribute_class);
+ free (attribute_class);
+
+ text_append_n (result, ">", 1);
+ if (specification->text)
+ text_append (result, specification->text);
+ text_append_n (result, "</", 2);
+ text_append (result, specification->element);
+ text_append_n (result, ">", 1);
+ }
+ else if (specification->text)
+ text_append (result, specification->text);
+}
+
+void
+convert_no_arg_command (CONVERTER *self, const enum command_id cmd,
+ const ELEMENT *element,
+ const HTML_ARGS_FORMATTED *args_formatted,
+ const char *content, TEXT *result)
+{
+ enum command_id formatted_cmd = cmd;
+ enum conversion_context context;
+ HTML_COMMAND_CONVERSION *specification;
+
+ if (html_in_preformatted_context (self) || html_in_math (self))
+ context = HCC_type_preformatted;
+ else if (html_in_string (self))
+ context = HCC_type_string;
+ else
+ context = HCC_type_normal;
+
+ if (cmd == CM_click)
+ {
+ enum command_id click_cmd = 0;
+ char *click_cmdname = lookup_extra_string (element, "clickstyle");
+ if (click_cmdname)
+ {
+ click_cmd = lookup_builtin_command (click_cmdname);
+ }
+ if (click_cmd)
+ {
+ HTML_COMMAND_CONVERSION *conv_context
+ = self->html_command_conversion[click_cmd];
+ if (conv_context[context].text || conv_context[context].element)
+ {
+ formatted_cmd = click_cmd;
+ }
+ }
+ }
+
+ if (html_in_upper_case (self)
+ && (builtin_command_data[formatted_cmd].other_flags & CF_letter_no_arg))
+ {
+ const char *command = builtin_command_name (formatted_cmd);
+ char *upper_case_command = strdup (command);
+ char *p;
+ enum command_id upper_case_cmd;
+ for (p = upper_case_command; *p; p++)
+ {
+ *p = toupper (*p);
+ }
+ /* TODO the mapping could be done once for all */
+ upper_case_cmd = lookup_builtin_command (upper_case_command);
+ if (upper_case_cmd)
+ {
+ HTML_COMMAND_CONVERSION *conv_context
+ = self->html_command_conversion[upper_case_cmd];
+ if (conv_context[context].text || conv_context[context].element)
+ formatted_cmd = upper_case_cmd;
+ }
+ }
+
+ specification
+ = &self->html_command_conversion[formatted_cmd][context];
+
+ text_element_conversion (self, specification, formatted_cmd, result);
+}
+
void
convert_w_command (CONVERTER *self, const enum command_id cmd,
const ELEMENT *element,
@@ -7316,6 +7411,24 @@ html_converter_initialize (CONVERTER *self)
}
}
+ /* all the no arg formatted commands are implemented in C */
+ if (self->no_arg_formatted_cmd.number)
+ {
+ for (i = 0; i < self->no_arg_formatted_cmd.number; i++)
+ {
+ enum command_id cmd = self->no_arg_formatted_cmd.list[i];
+ COMMAND_CONVERSION_FUNCTION *command_conversion
+ = &self->command_conversion_function[cmd];
+ if (command_conversion->status == FRS_status_default_set)
+ {
+ command_conversion->formatting_reference = 0;
+ command_conversion->status = FRS_status_internal;
+ command_conversion->command_conversion
+ = &convert_no_arg_command;
+ }
+ }
+ }
+
for (i = 0; commands_internal_open_table[i].command_open; i++)
{
enum command_id cmd = commands_internal_open_table[i].cmd;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/convert/convert_html.c (convert_no_arg_command) (text_element_conversion, html_converter_initialize): implement convert_no_arg_command.,
Patrice Dumas <=