[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/main/builtin_commands.c (element_
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/main/builtin_commands.c (element_builtin_cmd) (element_builtin_data_cmd): do not replace CM_item by CM_item_LINE if in a table term in element_builtin_cmd, do it in the new function element_builtin_data_cmd. Update callers. |
Date: |
Tue, 24 Oct 2023 13:10:09 -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 815397a2e6 * tp/Texinfo/XS/main/builtin_commands.c
(element_builtin_cmd) (element_builtin_data_cmd): do not replace CM_item by
CM_item_LINE if in a table term in element_builtin_cmd, do it in the new
function element_builtin_data_cmd. Update callers.
815397a2e6 is described below
commit 815397a2e6e17423428b3a8c4a802a019654b6ad
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Oct 24 14:13:39 2023 +0200
* tp/Texinfo/XS/main/builtin_commands.c (element_builtin_cmd)
(element_builtin_data_cmd): do not replace CM_item by CM_item_LINE if
in a table term in element_builtin_cmd, do it in the new function
element_builtin_data_cmd. Update callers.
* tp/Texinfo/Convert/HTML.pm (import),
tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_initialize_sv),
tp/Texinfo/XS/main/get_perl_info.c (html_converter_initialize_sv),
tp/Texinfo/XS/convert/convert_html.c (html_converter_initialize):
rename html_converter_initialize as html_converter_initialize_sv.
Add html_converter_initialize for converter initialization that can be
done in C only.
* tp/Texinfo/XS/convert/convert_html.c (enum argument_formatting_type)
(ARG_FORMATTED, ARGS_FORMATTED, MAX_COMMAND_ARGS_NR)
(COMMAND_ID_ARGS_SPECIFICATION, COMMAND_ID_ARGS_SPECIFICATION)
(default_commands_args, COMMAND_ARGS_SPECIFICATION)
(command_args_flags, html_converter_initialize)
(convert_to_html_internal): add a structure for default_commands_args,
using flags to determine how the different arguments should be
formatted. Copy to an array of commands_id, command_args_flags in
html_converter_initialize. Use the structure in
convert_to_html_internal for preliminary code that fills the
ARGS_FORMATTED structure.
* tp/Texinfo/Convert/HTML.pm (import, _XS_html_convert_convert)
(convert), tp/Texinfo/XS/convert/ConvertXS.xs (html_convert_convert),
tp/Texinfo/XS/convert/convert_html.c (convert_output_unit)
(convert_convert_output_unit_internal, html_convert_convert): add
preliminary XS interface for conversion in convert().
* tp/Texinfo/Convert/HTML.pm (convert_output_unit): rename $element as
$output_unit.
* tp/Texinfo/XS/convert/convert_html.c (convert_to_html_internal):
diverse fixes and improvements.
---
ChangeLog | 39 ++++
tp/Texinfo/Convert/HTML.pm | 26 ++-
tp/Texinfo/XS/convert/ConvertXS.xs | 32 +++-
tp/Texinfo/XS/convert/convert_html.c | 347 +++++++++++++++++++++++++++++++---
tp/Texinfo/XS/convert/convert_html.h | 8 +-
tp/Texinfo/XS/main/builtin_commands.c | 20 +-
tp/Texinfo/XS/main/builtin_commands.h | 1 +
tp/Texinfo/XS/main/convert_to_text.c | 2 +-
tp/Texinfo/XS/main/get_perl_info.c | 17 +-
tp/Texinfo/XS/main/get_perl_info.h | 12 +-
tp/Texinfo/XS/main/utils.c | 2 +-
tp/Texinfo/XS/main/utils.h | 2 +
12 files changed, 447 insertions(+), 61 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a12dfcd600..a85ea87f5f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,42 @@
+2023-10-24 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/builtin_commands.c (element_builtin_cmd)
+ (element_builtin_data_cmd): do not replace CM_item by CM_item_LINE if
+ in a table term in element_builtin_cmd, do it in the new function
+ element_builtin_data_cmd. Update callers.
+
+ * tp/Texinfo/Convert/HTML.pm (import),
+ tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_initialize_sv),
+ tp/Texinfo/XS/main/get_perl_info.c (html_converter_initialize_sv),
+ tp/Texinfo/XS/convert/convert_html.c (html_converter_initialize):
+ rename html_converter_initialize as html_converter_initialize_sv.
+ Add html_converter_initialize for converter initialization that can be
+ done in C only.
+
+ * tp/Texinfo/XS/convert/convert_html.c (enum argument_formatting_type)
+ (ARG_FORMATTED, ARGS_FORMATTED, MAX_COMMAND_ARGS_NR)
+ (COMMAND_ID_ARGS_SPECIFICATION, COMMAND_ID_ARGS_SPECIFICATION)
+ (default_commands_args, COMMAND_ARGS_SPECIFICATION)
+ (command_args_flags, html_converter_initialize)
+ (convert_to_html_internal): add a structure for default_commands_args,
+ using flags to determine how the different arguments should be
+ formatted. Copy to an array of commands_id, command_args_flags in
+ html_converter_initialize. Use the structure in
+ convert_to_html_internal for preliminary code that fills the
+ ARGS_FORMATTED structure.
+
+ * tp/Texinfo/Convert/HTML.pm (import, _XS_html_convert_convert)
+ (convert), tp/Texinfo/XS/convert/ConvertXS.xs (html_convert_convert),
+ tp/Texinfo/XS/convert/convert_html.c (convert_output_unit)
+ (convert_convert_output_unit_internal, html_convert_convert): add
+ preliminary XS interface for conversion in convert().
+
+ * tp/Texinfo/Convert/HTML.pm (convert_output_unit): rename $element as
+ $output_unit.
+
+ * tp/Texinfo/XS/convert/convert_html.c (convert_to_html_internal):
+ diverse fixes and improvements.
+
2023-10-23 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/HTML.pm (_convert): make code clearer and more
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 09a5f4a2bd..7ba44a7d76 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -96,7 +96,7 @@ sub import {
Texinfo::XSLoader::override(
"Texinfo::Convert::HTML::_XS_converter_initialize",
- "Texinfo::Convert::ConvertXS::html_converter_initialize");
+ "Texinfo::Convert::ConvertXS::html_converter_initialize_sv");
Texinfo::XSLoader::override(
"Texinfo::Convert::HTML::_XS_initialize_output_state",
"Texinfo::Convert::ConvertXS::html_initialize_output_state");
@@ -121,6 +121,9 @@ sub import {
Texinfo::XSLoader::override(
"Texinfo::Convert::HTML::_XS_html_convert_init",
"Texinfo::Convert::ConvertXS::html_convert_init");
+ Texinfo::XSLoader::override(
+ "Texinfo::Convert::HTML::_XS_html_convert_convert",
+ "Texinfo::Convert::ConvertXS::html_convert_convert");
$module_loaded = 1;
}
@@ -11031,6 +11034,10 @@ sub _XS_html_convert_init($)
{
}
+sub _XS_html_convert_convert($$$$)
+{
+}
+
sub convert($$)
{
my $self = shift;
@@ -11107,6 +11114,11 @@ sub convert($$)
# complete information should be available.
$self->_reset_info();
+ if ($self->{'converter_descriptor'}) {
+ my $XS_result = _XS_html_convert_convert ($encoded_converter, $root,
+ $output_units, $special_units);
+ }
+
if (!defined($output_units)) {
print STDERR "\nC NO UNIT\n" if ($self->get_conf('DEBUG'));
$result = $self->_convert($root, 'convert no unit');
@@ -11131,13 +11143,13 @@ sub convert($$)
sub convert_output_unit($$;$)
{
my $self = shift;
- my $element = shift;
+ my $output_unit = shift;
# only used for debug
my $explanation = shift;
$debug = $self->get_conf('DEBUG') if !defined($debug);
- my $unit_type_name = $element->{'unit_type'};
+ my $unit_type_name = $output_unit->{'unit_type'};
if (exists ($self->{'output_units_conversion'}->{$unit_type_name})
and !defined($self->{'output_units_conversion'}->{$unit_type_name})) {
@@ -11149,12 +11161,12 @@ sub convert_output_unit($$;$)
return '';
}
- $self->{'current_output_unit'} = $element;
+ $self->{'current_output_unit'} = $output_unit;
my $content_formatted = '';
- if ($element->{'unit_contents'}) {
+ if ($output_unit->{'unit_contents'}) {
my $content_idx = 0;
- foreach my $content (@{$element->{'unit_contents'}}) {
+ foreach my $content (@{$output_unit->{'unit_contents'}}) {
$content_formatted
.= _convert($self, $content, "$unit_type_name c[$content_idx]");
$content_idx++;
@@ -11165,7 +11177,7 @@ sub convert_output_unit($$;$)
$result
.= &{$self->{'output_units_conversion'}->{$unit_type_name}} ($self,
$unit_type_name,
- $element,
+ $output_unit,
$content_formatted);
} elsif (defined($content_formatted)) {
$result .= $content_formatted;
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 067b618550..4e48266050 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -94,7 +94,7 @@ text_convert_tree (text_options_in, tree_in, unused=0)
RETVAL
int
-html_converter_initialize (SV *converter_in, SV
*default_formatting_references, SV *default_css_string_formatting_references,
SV *default_commands_open, SV *default_commands_conversion, SV
*default_types_open, SV *default_types_conversion)
+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_types_open, SV *default_types_conversion)
void
html_initialize_output_state (SV *converter_in)
@@ -330,3 +330,33 @@ html_convert_init (SV *converter_in)
RETVAL = newSV(0);
OUTPUT:
RETVAL
+
+SV *
+html_convert_convert (SV *converter_in, SV *tree_in, SV *output_units_in, SV
*special_units_in)
+ PREINIT:
+ CONVERTER *self = 0;
+ DOCUMENT *document = 0;
+ int output_units_descriptor = 0;
+ int special_units_descriptor = 0;
+ char *result;
+ CODE:
+ self = get_sv_converter (converter_in, 0);
+ /* there could be strange results if the document and the converter
document
+ do not match. There is no reason why it would happen, though */
+ document = get_sv_tree_document (tree_in, 0);
+ if (SvOK (output_units_in))
+ output_units_descriptor
+ = get_sv_output_units_descriptor (output_units_in,
+ "html_prepare_output_units_global_targets output
units");
+ if (SvOK (special_units_in))
+ special_units_descriptor
+ = get_sv_output_units_descriptor (special_units_in,
+ "html_prepare_output_units_global_targets special
units");
+ result = html_convert_convert (self, document->tree,
+ output_units_descriptor,
+ special_units_descriptor);
+ RETVAL = newSVpv_utf8 (result, 0);
+ free (result);
+ OUTPUT:
+ RETVAL
+
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index a798433979..225ef383a0 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -43,6 +43,81 @@ typedef struct ROOT_AND_UNIT {
ELEMENT *root;
} ROOT_AND_UNIT;
+enum argument_formatting_type {
+ AFT_type_none,
+ AFT_type_normal,
+ AFT_type_string,
+ AFT_type_monospace,
+ AFT_type_monospacetext,
+ AFT_type_monospacestring,
+ AFT_type_filenametext,
+ AFT_type_url,
+ AFT_type_raw,
+};
+
+typedef struct ARG_FORMATTED {
+ ELEMENT *tree;
+ char *formatted[AFT_type_raw+1];
+} ARG_FORMATTED;
+
+typedef struct ARGS_FORMATTED {
+ size_t number;
+ ARG_FORMATTED *args;
+} ARGS_FORMATTED;
+
+/* unused */
+#define F_AFT_none 0x0001
+
+#define F_AFT_normal 0x0002
+#define F_AFT_string 0x0004
+#define F_AFT_monospace 0x0008
+#define F_AFT_monospacetext 0x0010
+#define F_AFT_monospacestring 0x0020
+#define F_AFT_filenametext 0x0040
+#define F_AFT_url 0x0080
+#define F_AFT_raw 0x0100
+
+/* in specification of args. Number max +1 for a trailing 0 */
+#define MAX_COMMAND_ARGS_NR 6
+
+typedef struct COMMAND_ID_ARGS_SPECIFICATION {
+ enum command_id cmd;
+ int flags[MAX_COMMAND_ARGS_NR];
+} COMMAND_ID_ARGS_SPECIFICATION;
+
+static COMMAND_ID_ARGS_SPECIFICATION default_commands_args[] = {
+ {CM_anchor, {F_AFT_monospacestring}},
+ {CM_email, {F_AFT_url | F_AFT_monospacestring, F_AFT_normal}},
+ {CM_footnote, {0}},
+ {CM_printindex, {0}},
+ {CM_uref, {F_AFT_url | F_AFT_monospacestring, F_AFT_normal, F_AFT_normal}},
+ {CM_url, {F_AFT_url | F_AFT_monospacestring, F_AFT_normal, F_AFT_normal}},
+ {CM_sp, {0}},
+ {CM_inforef, {F_AFT_monospace, F_AFT_normal, F_AFT_filenametext}},
+ {CM_xref, {F_AFT_monospace, F_AFT_normal, F_AFT_normal, F_AFT_filenametext,
F_AFT_normal}},
+ {CM_pxref, {F_AFT_monospace, F_AFT_normal, F_AFT_normal, F_AFT_filenametext,
F_AFT_normal}},
+ {CM_ref, {F_AFT_monospace, F_AFT_normal, F_AFT_normal, F_AFT_filenametext,
F_AFT_normal}},
+ {CM_link, {F_AFT_monospace, F_AFT_normal, F_AFT_filenametext}},
+ {CM_image, {F_AFT_url | F_AFT_filenametext | F_AFT_monospacestring,
F_AFT_filenametext, F_AFT_filenametext, F_AFT_string | F_AFT_normal,
F_AFT_filenametext}},
+ {CM_inlinefmt, {F_AFT_monospacetext, F_AFT_normal}},
+ {CM_inlinefmtifelse, {F_AFT_monospacetext, F_AFT_normal, F_AFT_normal}},
+ {CM_inlineraw, {F_AFT_monospacetext, F_AFT_raw}},
+ {CM_inlineifclear, {F_AFT_monospacetext, F_AFT_normal}},
+ {CM_inlineifset, {F_AFT_monospacetext, F_AFT_normal}},
+ {CM_item, {0}},
+ {CM_itemx, {0}},
+ {CM_value, {F_AFT_monospacestring}},
+ {CM_abbr, {F_AFT_normal, F_AFT_string}},
+ {CM_acronym, {F_AFT_normal, F_AFT_string}},
+};
+
+typedef struct COMMAND_ARGS_SPECIFICATION {
+ int status;
+ int flags [MAX_COMMAND_ARGS_NR];
+} COMMAND_ARGS_SPECIFICATION;
+
+static COMMAND_ARGS_SPECIFICATION command_args_flags[BUILTIN_CMD_NUMBER];
+
static void convert_to_html_internal (CONVERTER *self, ELEMENT *e,
TEXT *result, char *explanation);
@@ -728,6 +803,28 @@ prepare_special_units (CONVERTER *self, int
output_units_descriptor,
destroy_strings_list (do_special);
}
+/* most of the initialization is done by html_converter_initialize_sv
+ in get_perl_info, the initialization that sdo not require information
+ from perl is done here */
+void
+html_converter_initialize (CONVERTER *self)
+{
+ int i;
+ int nr_default_commands
+ = sizeof (default_commands_args) / sizeof (default_commands_args[0]);
+ int max_args = MAX_COMMAND_ARGS_NR;
+ for (i = 0; i < nr_default_commands; i++)
+ {
+ /* we file the status for specified commands, to distinguish them
+ but it is not actually used in the code, as we default to
+ normal for unspecified commands too */
+ enum command_id cmd = default_commands_args[i].cmd;
+ command_args_flags[cmd].status = 1;
+ memcpy (&command_args_flags[cmd].flags, &default_commands_args[i].flags,
+ max_args);
+ }
+}
+
void
html_initialize_output_state (CONVERTER *self)
{
@@ -2192,6 +2289,7 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
TEXT command_type;
char *debug_str;
char *command_name = element_command_name (element);
+ enum command_id cmd = element_builtin_cmd (element);
text_init (&command_type);
if (command_name)
@@ -2231,9 +2329,8 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
if ((element->type
&& self->types_conversion[element->type].status == FRS_status_ignored)
- || (element->cmd
- && self->commands_conversion[element->cmd].status
- == FRS_status_ignored))
+ || (cmd
+ && self->commands_conversion[cmd].status == FRS_status_ignored))
{
if (self->conf->DEBUG > 0)
{
@@ -2245,7 +2342,7 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
if (element->text.space > 0)
{
- char *result = 0;
+ char *result = "";
if (self->conf->DEBUG > 0)
{
@@ -2260,22 +2357,16 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
&& element->type != ET_definfoenclose_command
&& element->type != ET_index_entry_command))
{
- enum command_id cmd = element->cmd;
- enum command_id data_cmd = cmd;
- if (cmd == CM_item && item_line_parent (element))
- data_cmd = CM_item_LINE;
-
- /*
- if ($root_commands{$command_name}) {
- $self->{'current_root_command'} = $element;
- }
- */
+ enum command_id data_cmd = element_builtin_data_cmd (element);
+
+ if (builtin_command_data[data_cmd].flags & CF_root)
+ self->current_root_command = element;
if (self->commands_conversion[cmd].status)
{
int convert_to_latex = 0;
+ ARGS_FORMATTED *args_formatted = 0;
TEXT content_formatted;
- /* ?? args_formatted = 0; */
/* */
@@ -2314,14 +2405,24 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
|| cmd == CM_float
|| cmd == CM_cartouche)
{
- /* args_formatted */
if (element->args.number > 0)
{
+ TEXT formatted_arg;
int arg_idx;
+
+ text_init (&formatted_arg);
+
+ args_formatted = (ARGS_FORMATTED *)
+ malloc (sizeof (ARGS_FORMATTED));
+ args_formatted->number = element->args.number;
+ args_formatted->args = (ARG_FORMATTED *)
+ malloc (args_formatted->number * sizeof (ARG_FORMATTED));
+
/* */
for (arg_idx = 0; arg_idx < element->args.number; arg_idx++)
{
ELEMENT *arg = element->args.list[arg_idx];
+ char *explanation;
/* */
if (arg->contents.number <= 0)
/*
@@ -2332,27 +2433,77 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
/* */
continue;
}
+ int arg_flags = 0;
+ if (arg_idx < MAX_COMMAND_ARGS_NR
+ /* could check command_args_flags[cmd].status,
+ but it is probably faster not to */
+ && command_args_flags[cmd].flags[arg_idx])
+ arg_flags = command_args_flags[cmd].flags[arg_idx];
+ else
+ arg_flags = F_AFT_normal;
- /* for arg_type
- if */
+ ARG_FORMATTED *arg_formatted
+ = &args_formatted->args[arg_idx];
- char *explanation;
- TEXT arg_formatted;
- text_init (&arg_formatted);
- xasprintf (&explanation, "%s A[%d]$arg_type",
- command_type.text, arg_idx);
- convert_to_html_internal (self, arg, &arg_formatted,
- explanation);
- free (explanation);
- /* push @$args_formatted, $arg_formatted; */
+ arg_formatted->tree = arg;
+
+ if (arg_flags & F_AFT_normal)
+ {
+ text_reset (&formatted_arg);
+ if (convert_to_latex)
+ {
+ /* */
+ }
+ else
+ {
+ xasprintf (&explanation, "%s A[%d]normal",
+ command_type.text, arg_idx);
+ convert_to_html_internal (self, arg,
+ &formatted_arg,
+ explanation);
+ free (explanation);
+ }
+ arg_formatted->formatted[AFT_type_normal]
+ = strdup (formatted_arg.text);
+ }
+ if (arg_flags & F_AFT_monospace)
+ {
+ text_reset (&formatted_arg);
+ xasprintf (&explanation, "%s A[%d]monospace",
+ command_type.text, arg_idx);
+ /*
+ push @{$self->{'document_context'}->[-1]->{'monospace'}}, 1;
+ convert_to_html_internal ...
+ pop @{$self->{'document_context'}->[-1]->{'monospace'}};
+ */
+ convert_to_html_internal (self, arg, &formatted_arg,
+ explanation);
+
+ free (explanation);
+ arg_formatted->formatted[AFT_type_monospace]
+ = strdup (formatted_arg.text);
+ }
}
+ free (formatted_arg.text);
}
}
/* */
/* args are formatted, now format the command itself */
+ if (self->commands_conversion[cmd].status)
+ {
+ /*
+ $result .= &{$self->{'commands_conversion'}->{$command_name}}($self,
+ $command_name, $element, $args_formatted,
$content_formatted);
+ */
+ }
+ else if (args_formatted)
+ fprintf (stderr, "No command_conversion for %s\n",
+ command_name);
+
+ if (cmd == CM_documentlanguage)
+ html_translate_names (self);
- /* */
return;
}
else
@@ -2361,7 +2512,9 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
fprintf (stderr, "Command not converted: %s\n", command_name);
return;
}
- /* */
+
+ if (builtin_command_data[data_cmd].flags & CF_root)
+ self->current_root_command = 0;
}
else if (element->type)
{
@@ -2473,5 +2626,141 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
free (debug_str);
}
+char *
+convert_output_unit (CONVERTER *self, OUTPUT_UNIT *output_unit,
+ char *explanation)
+{
+ char *result;
+ TEXT content_formatted;
+ enum output_unit_type unit_type = output_unit->unit_type;
+
+/*
+ if (exists ($self->{'output_units_conversion'}->{$unit_type_name})
+ and !defined($self->{'output_units_conversion'}->{$unit_type_name})) {
+ if ($debug) {
+ my $string = 'IGNORED';
+ $string .= " $unit_type_name" if ($unit_type_name);
+ print STDERR "$string\n";
+ }
+ return '';
+ }
+ */
+
+ self->current_output_unit = output_unit;
+
+ text_init (&content_formatted);
+ text_append (&content_formatted, "");
+
+ if (output_unit->unit_contents.number > 0)
+ {
+ int content_idx;
+ for (content_idx = 0; content_idx < output_unit->unit_contents.number;
+ content_idx++)
+ {
+ ELEMENT *content = output_unit->unit_contents.list[content_idx];
+ char *explanation;
+ xasprintf (&explanation, "%s c[%d]",
+ output_unit_type_names[unit_type], content_idx);
+ convert_to_html_internal (self, content, &content_formatted,
+ explanation);
+ free (explanation);
+ }
+ }
+
+ if (0)
+ {
+ /*
+ if (exists($self->{'output_units_conversion'}->{$unit_type_name}))
+ $result
+ .= &{$self->{'output_units_conversion'}->{$unit_type_name}} ($self,
+ $unit_type_name,
+ $output_unit,
+ $content_formatted);
+ */
+ }
+ else
+ {
+ result = strdup (content_formatted.text);
+ }
+
+ self->current_output_unit = 0;
+
+ if (self->conf->DEBUG > 0)
+ fprintf (stderr, "UNIT (%s) => `%s'\n", output_unit_type_names[unit_type],
+ result);
+
+ return result;
+}
+
+/* wrapper to avoid code repetition and use similar functions as in perl */
+void
+convert_convert_output_unit_internal (CONVERTER *self, TEXT *result,
+ OUTPUT_UNIT *output_unit, int unit_nr)
+{
+ char *explanation;
+ char *output_unit_text;
+
+ if (self->conf->DEBUG > 0)
+ fprintf (stderr, "\nC UNIT %d\n", unit_nr);
+
+ xasprintf (&explanation, "convert unit %d", unit_nr);
+ output_unit_text = convert_output_unit (self, output_unit,
+ explanation);
+ text_append (result, output_unit_text);
+ free (explanation);
+ free (output_unit_text);
+}
+
+char *
+html_convert_convert (CONVERTER *self, ELEMENT *root,
+ int output_units_descriptor,
+ int special_units_descriptor)
+{
+ TEXT result;
+
+ OUTPUT_UNIT_LIST *output_units
+ = retrieve_output_units (output_units_descriptor);
+ OUTPUT_UNIT_LIST *special_units
+ = retrieve_output_units (special_units_descriptor);
+
+ text_init (&result);
+
+ if (!output_units || !output_units->number)
+ {
+
+ if (self->conf->DEBUG > 0)
+ fprintf (stderr, "\nC NO UNIT\n");
+
+ convert_to_html_internal (self, root, &result,
+ "convert no unit");
+ /*
+ $result .= &{$self->formatting_function('format_footnotes_segment')}($self);
+ */
+ }
+ else
+ {
+ int unit_nr = 0;
+ int i;
+ for (i = 0; i < output_units->number; i++)
+ {
+ OUTPUT_UNIT *output_unit = output_units->list[i];
+ convert_convert_output_unit_internal (self, &result,
+ output_unit, unit_nr);
+ unit_nr++;
+ }
+ if (special_units && special_units->number)
+ {
+ for (i = 0; i < output_units->number; i++)
+ {
+ OUTPUT_UNIT *output_unit = output_units->list[i];
+ convert_convert_output_unit_internal (self, &result,
+ output_unit, unit_nr);
+ unit_nr++;
+ }
+ }
+ }
+ return result.text;
+}
+
#undef ADD
diff --git a/tp/Texinfo/XS/convert/convert_html.h
b/tp/Texinfo/XS/convert/convert_html.h
index 00a9bb23db..cbdc916b5d 100644
--- a/tp/Texinfo/XS/convert/convert_html.h
+++ b/tp/Texinfo/XS/convert/convert_html.h
@@ -4,6 +4,8 @@
#include "utils.h"
+void html_converter_initialize (CONVERTER *self);
+
void html_initialize_output_state (CONVERTER *self);
void html_prepare_conversion_units (CONVERTER *self,
@@ -32,8 +34,8 @@ void html_translate_names (CONVERTER *self);
void html_convert_init (CONVERTER *self);
-/*
-char *html_convert (CONVERTER *self);
-*/
+char *html_convert_convert (CONVERTER *self, ELEMENT *root,
+ int output_units_descriptor,
+ int special_units_descriptor);
#endif
diff --git a/tp/Texinfo/XS/main/builtin_commands.c
b/tp/Texinfo/XS/main/builtin_commands.c
index dc86719f47..7d2b912052 100644
--- a/tp/Texinfo/XS/main/builtin_commands.c
+++ b/tp/Texinfo/XS/main/builtin_commands.c
@@ -78,15 +78,11 @@ element_command_name (ELEMENT *e)
return 0;
}
-/* map user-defined element commands to internal commands with the right
- flags associated */
+/* map user-defined element commands to internal commands */
+
enum command_id
element_builtin_cmd (ELEMENT *e)
{
- if (e->cmd == CM_item
- && e->parent->type == ET_table_term)
- return CM_item_LINE;
-
if (e->cmd && e->cmd < BUILTIN_CMD_NUMBER)
return e->cmd;
else if (e->type == ET_definfoenclose_command)
@@ -105,3 +101,15 @@ element_builtin_cmd (ELEMENT *e)
return 0;
}
+/* map user-defined element commands to internal commands with the right
+ flags associated */
+enum command_id
+element_builtin_data_cmd (ELEMENT *e)
+{
+ if (e->cmd == CM_item
+ && e->parent->type == ET_table_term)
+ return CM_item_LINE;
+
+ return element_builtin_cmd (e);
+}
+
diff --git a/tp/Texinfo/XS/main/builtin_commands.h
b/tp/Texinfo/XS/main/builtin_commands.h
index 0f82194223..3621f35b29 100644
--- a/tp/Texinfo/XS/main/builtin_commands.h
+++ b/tp/Texinfo/XS/main/builtin_commands.h
@@ -38,6 +38,7 @@ extern COMMAND builtin_command_data[];
enum command_id lookup_builtin_command (char *cmdname);
char *element_command_name (ELEMENT *e);
enum command_id element_builtin_cmd (ELEMENT *e);
+enum command_id element_builtin_data_cmd (ELEMENT *e);
/* Base command flags, .flags in COMMAND */
diff --git a/tp/Texinfo/XS/main/convert_to_text.c
b/tp/Texinfo/XS/main/convert_to_text.c
index cee356bc99..1fb0dc0119 100644
--- a/tp/Texinfo/XS/main/convert_to_text.c
+++ b/tp/Texinfo/XS/main/convert_to_text.c
@@ -313,7 +313,7 @@ convert_to_text_internal (ELEMENT *element, TEXT_OPTIONS
*text_options,
data_cmd need to be used for all access to arrays of command_id to
avoid an index > max index of builtin command */
if (element->cmd)
- data_cmd = element_builtin_cmd (element);
+ data_cmd = element_builtin_data_cmd (element);
if (!(element->type == ET_def_line)
&& ((element->type == ET_ignorable_spaces_after_command
diff --git a/tp/Texinfo/XS/main/get_perl_info.c
b/tp/Texinfo/XS/main/get_perl_info.c
index 6ec0a8319c..7bf4a994d7 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -40,11 +40,12 @@ FIXME add an initialization of translations?
#include "options_types.h"
#include "utils.h"
+#include "builtin_commands.h"
#include "document.h"
#include "output_unit.h"
#include "convert_to_text.h"
#include "converter.h"
-#include "builtin_commands.h"
+#include "convert_html.h"
#include "get_perl_info.h"
DOCUMENT *
@@ -428,12 +429,12 @@ register_formatting_reference_with_default (char
*type_string,
}
int
-html_converter_initialize (SV *sv_in, SV *default_formatting_references,
- SV *default_css_string_formatting_references,
- SV *default_commands_open,
- SV *default_commands_conversion,
- SV *default_types_open,
- SV *default_types_conversion)
+html_converter_initialize_sv (SV *sv_in, SV *default_formatting_references,
+ SV *default_css_string_formatting_references,
+ SV *default_commands_open,
+ SV *default_commands_conversion,
+ SV *default_types_open,
+ SV *default_types_conversion)
{
int i;
HV *hv_in;
@@ -493,6 +494,8 @@ html_converter_initialize (SV *sv_in, SV
*default_formatting_references,
/* HTML specific */
+ html_converter_initialize (converter);
+
FETCH(formatting_function);
/* no need to check if it exists */
diff --git a/tp/Texinfo/XS/main/get_perl_info.h
b/tp/Texinfo/XS/main/get_perl_info.h
index 87d97b8f19..42e85e6a2a 100644
--- a/tp/Texinfo/XS/main/get_perl_info.h
+++ b/tp/Texinfo/XS/main/get_perl_info.h
@@ -17,12 +17,12 @@ int get_sv_output_units_descriptor (SV *output_units_in,
char *warn_string);
OPTIONS *copy_sv_options (SV *sv_in);
TEXT_OPTIONS *copy_sv_options_for_convert_text (SV *sv_in);
-int html_converter_initialize (SV *sv_in, SV *default_formatting_references,
- SV *default_css_string_formatting_references,
- SV *default_commands_open,
- SV *default_commands_conversion,
- SV *default_types_open,
- SV *default_types_conversion);
+int html_converter_initialize_sv (SV *sv_in, SV *default_formatting_references,
+ SV *default_css_string_formatting_references,
+ SV *default_commands_open,
+ SV *default_commands_conversion,
+ SV *default_types_open,
+ SV *default_types_conversion);
CONVERTER *set_output_converter_sv (SV *sv_in, char *warn_string);
CONVERTER *get_sv_converter (SV *sv_in, char *warn_string);
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 11722237c9..b91c156386 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -889,7 +889,7 @@ informative_command_value (ELEMENT *element)
ELEMENT *misc_args;
char *text_arg;
- enum command_id cmd = element_builtin_cmd (element);
+ enum command_id cmd = element_builtin_data_cmd (element);
if (builtin_command_data[cmd].flags & CF_line
&& builtin_command_data[cmd].data == LINE_lineraw)
{
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index b5c7cd3b1d..d0510e48e8 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -386,6 +386,8 @@ typedef struct CONVERTER {
char *title_titlepage;
/* HTML specific */
+ ELEMENT *current_root_command;
+ OUTPUT_UNIT *current_output_unit;
OUTPUT_UNIT **global_units_directions;
SPECIAL_UNIT_DIRECTION **special_units_direction_name;
char **special_unit_info[SUI_type_heading+1];
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/main/builtin_commands.c (element_builtin_cmd) (element_builtin_data_cmd): do not replace CM_item by CM_item_LINE if in a table term in element_builtin_cmd, do it in the new function element_builtin_data_cmd. Update callers.,
Patrice Dumas <=