[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/convert/convert_html.c (convert_t
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/convert/convert_html.c (convert_to_html_internal), tp/Texinfo/XS/main/element_types.txt (text): add a virtual element type for all the elements holding text, and use it for the selection of the conversion function, similar to perl code. |
Date: |
Sat, 28 Oct 2023 10:33:35 -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 ab3ee90840 * tp/Texinfo/XS/convert/convert_html.c
(convert_to_html_internal), tp/Texinfo/XS/main/element_types.txt (text): add a
virtual element type for all the elements holding text, and use it for the
selection of the conversion function, similar to perl code.
ab3ee90840 is described below
commit ab3ee908403546464ed00edcf2aab4125c97c469
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Oct 28 16:33:37 2023 +0200
* tp/Texinfo/XS/convert/convert_html.c (convert_to_html_internal),
tp/Texinfo/XS/main/element_types.txt (text): add a virtual element
type for all the elements holding text, and use it for the selection
of the conversion function, similar to perl code.
* doc/texi2any_api.texi (Tree Element Conversion Functions): explain
the a text type is used to select formatting function for tree
elements with text.
---
ChangeLog | 11 +++++++++++
doc/texi2any_api.texi | 4 ++++
tp/Texinfo/XS/convert/convert_html.c | 28 +++++++++++++++-------------
tp/Texinfo/XS/main/element_types.c | 1 +
tp/Texinfo/XS/main/element_types.h | 1 +
tp/Texinfo/XS/main/element_types.txt | 4 ++++
6 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3633cdab54..47d7b5d5ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-10-28 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/convert_html.c (convert_to_html_internal),
+ tp/Texinfo/XS/main/element_types.txt (text): add a virtual element
+ type for all the elements holding text, and use it for the selection
+ of the conversion function, similar to perl code.
+
+ * doc/texi2any_api.texi (Tree Element Conversion Functions): explain
+ the a text type is used to select formatting function for tree
+ elements with text.
+
2023-10-28 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/Makefile.am (libtexinfoxs_la_SOURCES),
diff --git a/doc/texi2any_api.texi b/doc/texi2any_api.texi
index caeed2a0f4..3202da582e 100644
--- a/doc/texi2any_api.texi
+++ b/doc/texi2any_api.texi
@@ -2176,6 +2176,10 @@ conversion is usually done after formatting the contents
of the element,
but it may sometime be necessary to have some code run when
the element is first encountered.
+For tree elements that contain text, a @code{text} type is used
+to select the formatting functions, irrespective of the actual type of
+such a tree element. The @code{text} type is not used for tree elements.
+
For @@-commands with both a command name and a type, the type is used
as selector for the formating function for @code{def_line},
@code{definfoenclose_command} and @code{index_entry_command} types.
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 38fc012a28..f0320aa08b 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -2038,9 +2038,11 @@ command_conversion (CONVERTER *self, enum command_id cmd,
/* TODO call a C function if status is FRS_status_default_set
maybe putting function references in an array */
/* FIXME XS specific debug message */
+ /*
if (self->conf->DEBUG > 0)
fprintf (stderr, "DEBUG: command conversion %s '%s'\n",
builtin_command_data[cmd].cmdname, content);
+ */
if (self->commands_conversion[cmd].status > 0)
return call_commands_conversion (self, cmd, element,
args_formatted, content);
@@ -2727,12 +2729,12 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
}
else
{
- char *result = type_conversion (self, element->type, element,
- element->text.text);
- if (result)
+ char *conv_text = type_conversion (self, ET_text, element,
+ element->text.text);
+ if (conv_text)
{
- text_append (&text_result, result);
- free (result);
+ text_append (&text_result, conv_text);
+ free (conv_text);
}
}
@@ -2753,10 +2755,12 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
{
enum command_id data_cmd = element_builtin_data_cmd (element);
/* FIXME XS only debug message */
+ /*
if (self->conf->DEBUG > 0)
fprintf (stderr, "COMMAND: %s %s\n",
builtin_command_data[data_cmd].cmdname,
builtin_command_data[cmd].cmdname);
+ */
if (builtin_command_data[data_cmd].flags & CF_root)
{
@@ -2904,9 +2908,6 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
}
}
}
- /* FIXME XS only debug message */
- if (self->conf->DEBUG > 0)
- fprintf (stderr, "CM CONTENTS: '%s'\n", content_formatted.text);
if ((builtin_command_data[data_cmd].flags & CF_brace)
|| (builtin_command_data[data_cmd].flags & CF_line
@@ -3299,12 +3300,13 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
if (self->types_conversion[type].status)
{
- char *result = type_conversion (self, type, element,
- content_formatted.text);
- if (result)
+ char *conversion_result
+ = type_conversion (self, type, element,
+ content_formatted.text);
+ if (conversion_result)
{
- text_append (&type_result, result);
- free (result);
+ text_append (&type_result, conversion_result);
+ free (conversion_result);
}
}
else if (content_formatted.end > 0)
diff --git a/tp/Texinfo/XS/main/element_types.c
b/tp/Texinfo/XS/main/element_types.c
index 410cd47d49..3554adbef1 100644
--- a/tp/Texinfo/XS/main/element_types.c
+++ b/tp/Texinfo/XS/main/element_types.c
@@ -71,6 +71,7 @@ char *element_type_names[] = {
"macro_call",
"rmacro_call",
"linemacro_call",
+"text",
"_code",
"_converted",
"_string",
diff --git a/tp/Texinfo/XS/main/element_types.h
b/tp/Texinfo/XS/main/element_types.h
index c3e7a74fb2..dcb3e3a511 100644
--- a/tp/Texinfo/XS/main/element_types.h
+++ b/tp/Texinfo/XS/main/element_types.h
@@ -74,6 +74,7 @@ ET_untranslated,
ET_macro_call,
ET_rmacro_call,
ET_linemacro_call,
+ET_text,
ET__code,
ET__converted,
ET__string,
diff --git a/tp/Texinfo/XS/main/element_types.txt
b/tp/Texinfo/XS/main/element_types.txt
index 8769b50fe9..327493d08a 100644
--- a/tp/Texinfo/XS/main/element_types.txt
+++ b/tp/Texinfo/XS/main/element_types.txt
@@ -103,6 +103,10 @@ macro_call
rmacro_call
linemacro_call
+# virtual type not corresponding to a specific element in tree, but
+# used for all the elements that hold text, typically in converters.
+text
+
# for HTML converter
_code
_converted
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/convert/convert_html.c (convert_to_html_internal), tp/Texinfo/XS/main/element_types.txt (text): add a virtual element type for all the elements holding text, and use it for the selection of the conversion function, similar to perl code.,
Patrice Dumas <=