[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/HTML.pm (_prepare_conversion
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Convert/HTML.pm (_prepare_conversion_units, convert) (output): set contents and shortcontents early in convert and output, where other configurations options are set, and not in _prepare_conversion_units. |
Date: |
Mon, 30 Oct 2023 07:08:44 -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 be90a3d8e2 * tp/Texinfo/Convert/HTML.pm (_prepare_conversion_units,
convert) (output): set contents and shortcontents early in convert and output,
where other configurations options are set, and not in
_prepare_conversion_units.
be90a3d8e2 is described below
commit be90a3d8e257900bfa97eb5fe04e9f90fd675020
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Oct 30 13:08:47 2023 +0100
* tp/Texinfo/Convert/HTML.pm (_prepare_conversion_units, convert)
(output): set contents and shortcontents early in convert and
output, where other configurations options are set, and not in
_prepare_conversion_units.
* tp/Texinfo/XS/convert/convert_html.c (html_convert_convert): convert
special units instead of output units twice...
* tp/Texinfo/XS/main/build_perl_info.c (build_html_document_context):
add missing call of build_html_document_context_ctx.
* tp/Texinfo/XS/main/convert_to_texinfo.c
(root_heading_command_to_texinfo): initialize tree, fix nesting of
if, free text representation of command.
* tp/Texinfo/Convert/Texinfo.pm (root_heading_command_to_texinfo):
reorganize code, no functional change.
* tp/Texinfo/Convert/HTML.pm (convert_output_unit),
tp/Texinfo/XS/convert/convert_html.c (convert_output_unit): better debug
for output units conversion.
* tp/Texinfo/XS/convert/convert_html.c (prepare_footnotes_targets):
free footnote texinfo content in debug message.
* tp/Texinfo/XS/convert/convert_html.c (html_translate_names):
add encoding_name in debug message.
---
ChangeLog | 30 ++++++++++++++++++++++++++
tp/Texinfo/Convert/HTML.pm | 28 ++++++++++++++++++-------
tp/Texinfo/Convert/Texinfo.pm | 9 +++++---
tp/Texinfo/XS/convert/convert_html.c | 37 +++++++++++++++++++++++----------
tp/Texinfo/XS/convert/converter.c | 2 +-
tp/Texinfo/XS/main/build_perl_info.c | 2 ++
tp/Texinfo/XS/main/convert_to_texinfo.c | 16 ++++++++------
7 files changed, 95 insertions(+), 29 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a2925ffe81..d37e9baf03 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2023-10-30 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm (_prepare_conversion_units, convert)
+ (output): set contents and shortcontents early in convert and
+ output, where other configurations options are set, and not in
+ _prepare_conversion_units.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_convert_convert): convert
+ special units instead of output units twice...
+
+ * tp/Texinfo/XS/main/build_perl_info.c (build_html_document_context):
+ add missing call of build_html_document_context_ctx.
+
+ * tp/Texinfo/XS/main/convert_to_texinfo.c
+ (root_heading_command_to_texinfo): initialize tree, fix nesting of
+ if, free text representation of command.
+
+ * tp/Texinfo/Convert/Texinfo.pm (root_heading_command_to_texinfo):
+ reorganize code, no functional change.
+
+ * tp/Texinfo/Convert/HTML.pm (convert_output_unit),
+ tp/Texinfo/XS/convert/convert_html.c (convert_output_unit): better debug
+ for output units conversion.
+
+ * tp/Texinfo/XS/convert/convert_html.c (prepare_footnotes_targets):
+ free footnote texinfo content in debug message.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_translate_names):
+ add encoding_name in debug message.
+
2023-10-29 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/utils.h (TRANSLATED_SUI_ASSOCIATION),
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 741ca55d96..2573c62a41 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -9290,13 +9290,6 @@ sub _prepare_conversion_units($$$)
my ($output_units, $special_units, $associated_special_units);
- # the presence of contents elements in the document is used in diverse
- # places, set it once for all here
- my @contents_elements_options
- = grep {Texinfo::Common::valid_customization_option($_)}
- sort(keys(%contents_command_special_unit_variety));
- $self->set_global_document_commands('last', \@contents_elements_options);
-
if ($self->{'converter_descriptor'}) {
my $encoded_converter = $self->encode_converter_for_output();
my $encoded_document_name = Encode::encode('UTF-8', $document_name);
@@ -11061,6 +11054,13 @@ sub convert($$)
# needed for CSS rules gathering
$self->{'current_filename'} = '';
+ # the presence of contents elements in the document is used in diverse
+ # places, set it once for all here
+ my @contents_elements_options
+ = grep {Texinfo::Common::valid_customization_option($_)}
+ sort(keys(%contents_command_special_unit_variety));
+ $self->set_global_document_commands('last', \@contents_elements_options);
+
# call before _prepare_conversion_units.
# Some information is not available yet.
$self->_reset_info();
@@ -11168,6 +11168,11 @@ sub convert_output_unit($$;$)
return '';
}
+ if ($debug) {
+ print STDERR "UNIT($explanation) -> ou: $unit_type_name '"
+ .Texinfo::Structuring::output_unit_texi($output_unit)."'\n";
+ }
+
$self->{'current_output_unit'} = $output_unit;
my $content_formatted = '';
@@ -11192,7 +11197,7 @@ sub convert_output_unit($$;$)
delete $self->{'current_output_unit'};
- print STDERR "UNIT ($unit_type_name) => `$result'\n" if $debug;
+ print STDERR "DOUNIT ($unit_type_name) => `$result'\n" if $debug;
return $result;
}
@@ -11416,6 +11421,13 @@ sub output($$)
'lang="' . $structure_preamble_document_language . '"');
$self->set_global_document_commands('before', ['documentlanguage']);
+ # the presence of contents elements in the document is used in diverse
+ # places, set it once for all here
+ my @contents_elements_options
+ = grep {Texinfo::Common::valid_customization_option($_)}
+ sort(keys(%contents_command_special_unit_variety));
+ $self->set_global_document_commands('last', \@contents_elements_options);
+
$self->{'jslicenses'} = {};
if ($self->get_conf('HTML_MATH')
and $self->get_conf('HTML_MATH') eq 'mathjax') {
diff --git a/tp/Texinfo/Convert/Texinfo.pm b/tp/Texinfo/Convert/Texinfo.pm
index 5d17faeba3..8a91570840 100644
--- a/tp/Texinfo/Convert/Texinfo.pm
+++ b/tp/Texinfo/Convert/Texinfo.pm
@@ -159,9 +159,12 @@ sub root_heading_command_to_texinfo($)
} else {
return "Not a command";
}
- return '@'.$element->{'cmdname'}.' '.convert_to_texinfo({'contents' =>
$tree})
- if ($tree);
- return '@'.$element->{'cmdname'};
+ if ($tree) {
+ return '@'.$element->{'cmdname'}.' '
+ .convert_to_texinfo({'contents' => $tree});
+ } else {
+ return '@'.$element->{'cmdname'};
+ }
}
# Following subroutines deal with transforming a texinfo tree into texinfo
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index afb38de3ea..17bf26457e 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -1275,8 +1275,10 @@ prepare_footnotes_targets (CONVERTER *self)
if (self->conf->DEBUG > 0)
{
+ char *footnote_txi = convert_to_texinfo (footnote);
fprintf (stderr, "Enter footnote: target %s, nr %d\n%s\n",
- footid.text, nr, convert_to_texinfo (footnote));
+ footid.text, nr, footnote_txi);
+ free (footnote_txi);
}
}
}
@@ -2505,8 +2507,9 @@ html_translate_names (CONVERTER *self)
if (self->conf->DEBUG > 0)
{
- fprintf (stderr, "\nTRANSLATE_NAMES encoding_name: "
- " documentlanguage: %s\n", self->conf->documentlanguage);
+ fprintf (stderr, "\nTRANSLATE_NAMES encoding_name: %s"
+ " documentlanguage: %s\n",
+ self->conf->OUTPUT_ENCODING_NAME, self->conf->documentlanguage);
}
/* reset strings such that they are translated when needed. */
@@ -2689,8 +2692,7 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
text_append (&contexts_str, "UNDEF");
}
- text_printf (&debug_str, "XS|ELEMENT(%s) %p (%s), ->", explanation,
- &self->commands_conversion,
+ text_printf (&debug_str, "XS|ELEMENT(%s) (%s), ->", explanation,
contexts_str.text);
free (contexts_str.text);
if (command_name)
@@ -2757,7 +2759,7 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
if (self->conf->DEBUG > 0)
{
- fprintf (stderr, "DO TEXT => `%s'\n", text_result.text);
+ fprintf (stderr, "XS|DO TEXT => `%s'\n", text_result.text);
}
ADD(text_result.text);
@@ -3017,15 +3019,19 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
0, 0);
string_document_ctx = top_document_context (self);
string_document_ctx->string_ctx++;
+
self->modified_state |= HMSF_document_context;
+
xasprintf (&explanation, "%s A[%d]string",
command_type.text, arg_idx);
convert_to_html_internal (self, arg, &formatted_arg,
explanation);
free (explanation);
+
html_pop_document_context (self);
self->modified_state |= HMSF_document_context;
+
arg_formatted->formatted[AFT_type_string]
= strdup (formatted_arg.text);
}
@@ -3358,7 +3364,7 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
if (self->conf->DEBUG > 0)
{
- fprintf (stderr, "DO type (%s) => `%s'\n", type_name,
+ fprintf (stderr, "XS|DO type (%s) => `%s'\n", type_name,
type_result.text);
}
ADD(type_result.text);
@@ -3448,6 +3454,15 @@ convert_output_unit (CONVERTER *self, OUTPUT_UNIT
*output_unit,
return strdup ("");
}
+ if (self->conf->DEBUG > 0)
+ {
+ char *output_unit_txi = output_unit_texi(output_unit);
+ fprintf (stderr, "XS|UNIT(%s) -> ou: %s '%s'\n", explanation,
+ output_unit_type_names[unit_type],
+ output_unit_txi);
+ free (output_unit_txi);
+ }
+
self->current_output_unit = output_unit;
self->modified_state |= HMSF_current_output_unit;
@@ -3488,7 +3503,7 @@ convert_output_unit (CONVERTER *self, OUTPUT_UNIT
*output_unit,
self->modified_state |= HMSF_current_output_unit;
if (self->conf->DEBUG > 0)
- fprintf (stderr, "UNIT (%s) => `%s'\n", output_unit_type_names[unit_type],
+ fprintf (stderr, "DOUNIT (%s) => `%s'\n",
output_unit_type_names[unit_type],
result);
return result;
@@ -3552,11 +3567,11 @@ html_convert_convert (CONVERTER *self, ELEMENT *root,
}
if (special_units && special_units->number)
{
- for (i = 0; i < output_units->number; i++)
+ for (i = 0; i < special_units->number; i++)
{
- OUTPUT_UNIT *output_unit = output_units->list[i];
+ OUTPUT_UNIT *special_unit = special_units->list[i];
convert_convert_output_unit_internal (self, &result,
- output_unit, unit_nr);
+ special_unit, unit_nr);
unit_nr++;
}
}
diff --git a/tp/Texinfo/XS/convert/converter.c
b/tp/Texinfo/XS/convert/converter.c
index a5e4e48fba..49934d339f 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -188,7 +188,7 @@ set_global_document_commands (CONVERTER *converter,
enum command_id cmd = cmd_list[i];
if (converter->conf->DEBUG > 0)
{
- fprintf (stderr, "SET_global(%s) %s\n",
+ fprintf (stderr, "XS|SET_global(%s) %s\n",
command_location_names[location],
builtin_command_data[cmd].cmdname);
}
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 7d6272198b..232b8b4bc3 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -2150,6 +2150,8 @@ build_html_document_context (HTML_DOCUMENT_CONTEXT
*document_context)
hv = newHV ();
+ build_html_document_context_ctx (hv, document_context);
+
#define STORE(key, value) hv_store (hv, key, strlen (key), value, 0)
STORE ("context", newSVpv_utf8 (document_context->context, 0));
diff --git a/tp/Texinfo/XS/main/convert_to_texinfo.c
b/tp/Texinfo/XS/main/convert_to_texinfo.c
index c654e31ab0..93759b5955 100644
--- a/tp/Texinfo/XS/main/convert_to_texinfo.c
+++ b/tp/Texinfo/XS/main/convert_to_texinfo.c
@@ -311,22 +311,26 @@ check_node_same_texinfo_code (ELEMENT *reference_node,
ELEMENT *node_content)
char *
root_heading_command_to_texinfo (ELEMENT *element)
{
- ELEMENT *tree;
+ ELEMENT *tree = 0;
TEXT text;
if (element->cmd)
- if ((element->cmd == CM_node
- || (builtin_command_flags (element) & CF_sectioning_heading))
- && element->args.number > 0)
- tree = element->args.list[0];
+ {
+ if ((element->cmd == CM_node
+ || (builtin_command_flags (element) & CF_sectioning_heading))
+ && element->args.number > 0)
+ tree = element->args.list[0];
+ }
else
return strdup("Not a command");
text_init (&text);
if (tree)
{
+ char *tree_txi = convert_contents_to_texinfo (tree);
text_printf (&text, "@%s %s", builtin_command_name (element->cmd),
- convert_contents_to_texinfo (tree));
+ tree_txi);
+ free (tree_txi);
}
else
text_printf (&text, "@%s", builtin_command_name (element->cmd));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/HTML.pm (_prepare_conversion_units, convert) (output): set contents and shortcontents early in convert and output, where other configurations options are set, and not in _prepare_conversion_units.,
Patrice Dumas <=