[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Wed, 2 Oct 2024 05:59:25 -0400 (EDT) |
branch: master
commit 4006d4ca49bfe81874594b02784263d9b72b42e7
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Jul 30 18:54:07 2024 +0200
* tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
(@all_directions_except_special_units, converter_initialize)
(conversion_initialization): do not use default directions trings
directions to apply customized direction strings, merge the directions
that never change, global relative and file, and the special units
directions that may be customized.
* tp/Texinfo/XS/convert/get_html_perl_info.c
(html_converter_initialize_sv): fix code getting context values of
customized_direction_strings.
* tp/Makefile.am (test_files), tp/Makefile.tres,
tp/t/init/special_unit_direction_string_info_customization.pm,
tp/t/init_files_tests.t
(button_replacement_direction_strings_customization): test irection
customization and button direction replacement and direction strings
customization for the modified special unit direction.
---
ChangeLog | 20 ++
tp/Makefile.am | 1 +
tp/Makefile.tres | 2 +
tp/Texinfo/Convert/HTML.pm | 34 ++-
tp/Texinfo/XS/convert/get_html_perl_info.c | 37 ++-
tp/t/init_files_tests.t | 7 +-
..._replacement_direction_strings_customization.pl | 290 +++++++++++++++++++++
.../res_html/chapter.html | 41 +++
.../res_html/index.html | 58 +++++
9 files changed, 469 insertions(+), 21 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0fd0c9e92d..93867b8449 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,26 @@
(converter_initialize): readd converter_initialize that was mistakenly
removed.
+2024-07-30 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
+ (@all_directions_except_special_units, converter_initialize)
+ (conversion_initialization): do not use default directions trings
+ directions to apply customized direction strings, merge the directions
+ that never change, global relative and file, and the special units
+ directions that may be customized.
+
+ * tp/Texinfo/XS/convert/get_html_perl_info.c
+ (html_converter_initialize_sv): fix code getting context values of
+ customized_direction_strings.
+
+ * tp/Makefile.am (test_files), tp/Makefile.tres,
+ tp/t/init/special_unit_direction_string_info_customization.pm,
+ tp/t/init_files_tests.t
+ (button_replacement_direction_strings_customization): test irection
+ customization and button direction replacement and direction strings
+ customization for the modified special unit direction.
+
2024-07-30 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_initialize_sv),
diff --git a/tp/Makefile.am b/tp/Makefile.am
index c234d78326..20f2583f9a 100644
--- a/tp/Makefile.am
+++ b/tp/Makefile.am
@@ -206,6 +206,7 @@ test_files = \
t/init/set_unit_file_name_filepath.pm \
t/init/special_element_customization.pm \
t/init/special_unit_direction_customization.pm \
+ t/init/special_unit_direction_string_info_customization.pm \
t/init/t2h_buttons.pm \
t/init/t2h_singular.init \
t/init/test_css_info_functions.pm \
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 51ef94b326..d3f78b69ae 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -1104,6 +1104,8 @@ test_files_generated_list =
$(test_tap_files_generated_list) \
t/results/init_files_tests/access_document_name_in_handler/res_html \
t/results/init_files_tests/button_replacement_and_direction_customization.pl
\
t/results/init_files_tests/button_replacement_and_direction_customization/res_html
\
+
t/results/init_files_tests/button_replacement_direction_strings_customization.pl
\
+
t/results/init_files_tests/button_replacement_direction_strings_customization/res_html
\
t/results/init_files_tests/button_replacement_for_special_unit_direction.pl \
t/results/init_files_tests/button_replacement_for_special_unit_direction/res_html
\
t/results/init_files_tests/customize_special_element.pl \
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index a0c67292bb..9d8f7b175e 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -2615,15 +2615,13 @@ my $direction_orders =
Texinfo::Data::get_directions_order();
# 'global', 'relative', 'file'
# include space direction
my @global_directions_order = @{$direction_orders->[0]};
-my %global_and_special_directions;
-foreach my $global_direction (@global_directions_order) {
- $global_and_special_directions{$global_direction} = 1;
-}
-foreach my $special_direction (values(
- %{$default_special_unit_info{'direction'}})) {
- $global_and_special_directions{$special_direction} = 1;
+my @all_directions_except_special_units;
+foreach my $direction_order (@$direction_orders) {
+ push @all_directions_except_special_units, @$direction_order;
}
+#print STDERR join('|', @all_directions_except_special_units)."\n";
+
# for rel, see http://www.w3.org/TR/REC-html40/types.html#type-links
my %default_converted_directions_strings
= %{ Texinfo::Data::get_default_converted_directions_strings() };
@@ -9014,6 +9012,15 @@ sub converter_initialize($)
= $customized_special_unit_body->{$special_unit_variety};
}
+ my @all_directions = @all_directions_except_special_units;
+ foreach my $variety (keys(%{$self->{'special_unit_info'}->{'direction'}})) {
+ my $direction = $self->{'special_unit_info'}->{'direction'}->{$variety};
+ if (defined($direction)) {
+ push @all_directions, $direction;
+ }
+ }
+ #print STDERR join('|', @all_directions)."\n";
+
# Fill the translated direction strings information, corresponding to:
# - strings already converted
# - strings not already converted
@@ -9024,8 +9031,7 @@ sub converter_initialize($)
$self->{'translated_direction_strings'} = {};
foreach my $string_type (keys(%default_translated_directions_strings)) {
$self->{'translated_direction_strings'}->{$string_type} = {};
- foreach my $direction
- (keys(%{$default_translated_directions_strings{$string_type}})) {
+ foreach my $direction (@all_directions) {
if ($customized_direction_strings->{$string_type}
and $customized_direction_strings->{$string_type}->{$direction}) {
$self->{'translated_direction_strings'}->{$string_type}->{$direction}
@@ -12034,6 +12040,13 @@ sub conversion_initialization($$;$)
}
}
+ my @all_directions = @all_directions_except_special_units;
+ foreach my $variety (keys(%{$self->{'special_unit_info'}->{'direction'}})) {
+ my $direction = $self->{'special_unit_info'}->{'direction'}->{$variety};
+ if (defined($direction)) {
+ push @all_directions, $direction;
+ }
+ }
# three types of direction strings:
# * strings not translated, already converted
# * strings translated
@@ -12046,8 +12059,7 @@ sub conversion_initialization($$;$)
# substitute_html_non_breaking_space is used and it depends on the document.
foreach my $string_type (keys(%default_converted_directions_strings)) {
$self->{'directions_strings'}->{$string_type} = {};
- foreach my $direction
- (keys(%{$default_converted_directions_strings{$string_type}})) {
+ foreach my $direction (@all_directions) {
$self->{'directions_strings'}->{$string_type}->{$direction} = {};
my $string_contexts;
if ($self->{'customized_direction_strings'}->{$string_type}
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index 5b0413dcc3..682922a866 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -1177,7 +1177,7 @@ html_converter_initialize_sv (SV *converter_sv,
const char *direction_name;
if (direction_hv)
{
- SV **context_sv;
+ SV **spec_sv;
if (i < FIRSTINFILE_MIN_IDX)
direction_name = html_button_direction_names[i];
@@ -1186,14 +1186,14 @@ html_converter_initialize_sv (SV *converter_sv,
= converter->special_unit_info[SUI_type_direction]
[i - FIRSTINFILE_MIN_IDX];
- context_sv = hv_fetch (direction_hv, direction_name,
+ spec_sv = hv_fetch (direction_hv, direction_name,
strlen (direction_name), 0);
- if (context_sv)
+ if (spec_sv)
{
- if (SvOK (*context_sv))
+ if (SvOK (*spec_sv))
{
- HV *context_hv = (HV *) SvRV (*context_sv);
- SV **converted_sv = hv_fetch (context_hv,
"converted",
+ HV *spec_hv = (HV *) SvRV (*spec_sv);
+ SV **context_sv = hv_fetch (spec_hv, "converted",
strlen ("converted"),
0);
converter->
@@ -1204,10 +1204,10 @@ html_converter_initialize_sv (SV *converter_sv,
customized_directions_strings[customized_type][i], 0,
nr_dir_str_contexts * sizeof (char *));
- if (converted_sv && SvOK (*converted_sv))
+ if (context_sv && SvOK (*context_sv))
{
int j;
-
+ HV *context_hv = (HV *) SvRV (*context_sv);
for (j = 0; j < nr_dir_str_contexts; j++)
{
const char *context_name
@@ -1225,12 +1225,31 @@ html_converter_initialize_sv (SV *converter_sv,
[customized_type][i][j]
= strdup (value);
}
+ /* in general no string value, it is completed later on
+ in C code
+ else
+ {
+ fprintf (stderr,
+ "customized_direction_strings: %s: %s: %s: no value\n",
+ type_name, direction_name,
+ context_name);
+ }
+ */
}
}
+ /* case of customized string undef
+ else
+ {
+ fprintf (stderr,
+ "customized_direction_strings: %s: %s: spec SvTYPE %d no converted\n",
+ type_name, direction_name,
+ SvTYPE (SvRV (*spec_sv)));
+ }
+ */
continue;
}
}
- /* this happens if the direction strings are undef
+ /* for debug, case of directions not customized
else
{
fprintf (stderr,
diff --git a/tp/t/init_files_tests.t b/tp/t/init_files_tests.t
index 8d2ffd3439..193156beef 100644
--- a/tp/t/init_files_tests.t
+++ b/tp/t/init_files_tests.t
@@ -281,7 +281,12 @@ $special_unit_direction_customization_text,
{'init_files' => ['special_unit_direction_customization.pm',
'button_replacement_for_special_unit_direction.pm']},
],
-
+['button_replacement_direction_strings_customization',
+$special_unit_direction_customization_text,
+{'init_files' => ['special_unit_direction_customization.pm',
+ 'button_replacement_for_special_unit_direction.pm',
+ 'special_unit_direction_string_info_customization.pm']},
+],
);
foreach my $test (@test_cases) {
diff --git
a/tp/t/results/init_files_tests/button_replacement_direction_strings_customization.pl
b/tp/t/results/init_files_tests/button_replacement_direction_strings_customization.pl
new file mode 100644
index 0000000000..5e0498d13f
--- /dev/null
+++
b/tp/t/results/init_files_tests/button_replacement_direction_strings_customization.pl
@@ -0,0 +1,290 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors
+ %result_indices %result_sectioning %result_nodes %result_menus
+ %result_floats %result_converted %result_converted_errors
+ %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'button_replacement_direction_strings_customization'} = {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'text' => '
+',
+ 'type' => 'rawline_arg'
+ }
+ ],
+ 'cmdname' => 'contents',
+ 'extra' => {},
+ 'source_info' => {
+ 'line_nr' => 1
+ }
+ },
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ }
+ ],
+ 'type' => 'preamble_before_content'
+ }
+ ],
+ 'type' => 'before_node_section'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'Top'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => {
+ 'text' => '
+'
+ }
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'is_target' => 1,
+ 'normalized' => 'Top'
+ },
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'source_info' => {
+ 'line_nr' => 3
+ }
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'top'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => {
+ 'text' => '
+'
+ }
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'top',
+ 'contents' => [
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ }
+ ],
+ 'extra' => {},
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'source_info' => {
+ 'line_nr' => 4
+ }
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'chapter'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => {
+ 'text' => '
+'
+ }
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'is_target' => 1,
+ 'normalized' => 'chapter'
+ },
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'source_info' => {
+ 'line_nr' => 6
+ }
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'chap'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => {
+ 'text' => '
+'
+ }
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'chapter',
+ 'extra' => {
+ 'section_number' => '1'
+ },
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'source_info' => {
+ 'line_nr' => 7
+ }
+ }
+ ],
+ 'type' => 'document_root'
+};
+
+$result_texis{'button_replacement_direction_strings_customization'} =
'@contents
+
+@node Top
+@top top
+
+@node chapter
+@chapter chap
+';
+
+
+$result_texts{'button_replacement_direction_strings_customization'} = '
+top
+***
+
+1 chap
+******
+';
+
+$result_sectioning{'button_replacement_direction_strings_customization'} = {
+ 'extra' => {
+ 'section_childs' => [
+ {
+ 'cmdname' => 'top',
+ 'extra' => {
+ 'associated_node' => {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'normalized' => 'Top'
+ }
+ },
+ 'section_childs' => [
+ {
+ 'cmdname' => 'chapter',
+ 'extra' => {
+ 'associated_node' => {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'normalized' => 'chapter'
+ }
+ },
+ 'section_directions' => {
+ 'up' => {}
+ },
+ 'section_level' => 1,
+ 'section_number' => '1',
+ 'toplevel_directions' => {
+ 'prev' => {},
+ 'up' => {}
+ }
+ }
+ }
+ ],
+ 'section_level' => 0,
+ 'sectioning_root' => {},
+ 'toplevel_directions' => {}
+ }
+ }
+ ],
+ 'section_level' => -1
+ }
+};
+$result_sectioning{'button_replacement_direction_strings_customization'}{'extra'}{'section_childs'}[0]{'extra'}{'section_childs'}[0]{'extra'}{'section_directions'}{'up'}
=
$result_sectioning{'button_replacement_direction_strings_customization'}{'extra'}{'section_childs'}[0];
+$result_sectioning{'button_replacement_direction_strings_customization'}{'extra'}{'section_childs'}[0]{'extra'}{'section_childs'}[0]{'extra'}{'toplevel_directions'}{'prev'}
=
$result_sectioning{'button_replacement_direction_strings_customization'}{'extra'}{'section_childs'}[0];
+$result_sectioning{'button_replacement_direction_strings_customization'}{'extra'}{'section_childs'}[0]{'extra'}{'section_childs'}[0]{'extra'}{'toplevel_directions'}{'up'}
=
$result_sectioning{'button_replacement_direction_strings_customization'}{'extra'}{'section_childs'}[0];
+$result_sectioning{'button_replacement_direction_strings_customization'}{'extra'}{'section_childs'}[0]{'extra'}{'sectioning_root'}
= $result_sectioning{'button_replacement_direction_strings_customization'};
+
+$result_nodes{'button_replacement_direction_strings_customization'} = [
+ {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'associated_section' => {
+ 'cmdname' => 'top',
+ 'extra' => {}
+ },
+ 'node_directions' => {
+ 'next' => {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'associated_section' => {
+ 'cmdname' => 'chapter',
+ 'extra' => {
+ 'section_number' => '1'
+ }
+ },
+ 'node_directions' => {
+ 'prev' => {},
+ 'up' => {}
+ },
+ 'normalized' => 'chapter'
+ }
+ }
+ },
+ 'normalized' => 'Top'
+ }
+ },
+ {}
+];
+$result_nodes{'button_replacement_direction_strings_customization'}[0]{'extra'}{'node_directions'}{'next'}{'extra'}{'node_directions'}{'prev'}
= $result_nodes{'button_replacement_direction_strings_customization'}[0];
+$result_nodes{'button_replacement_direction_strings_customization'}[0]{'extra'}{'node_directions'}{'next'}{'extra'}{'node_directions'}{'up'}
= $result_nodes{'button_replacement_direction_strings_customization'}[0];
+$result_nodes{'button_replacement_direction_strings_customization'}[1] =
$result_nodes{'button_replacement_direction_strings_customization'}[0]{'extra'}{'node_directions'}{'next'};
+
+$result_menus{'button_replacement_direction_strings_customization'} = [
+ {
+ 'extra' => {
+ 'normalized' => 'Top'
+ }
+ },
+ {
+ 'extra' => {
+ 'normalized' => 'chapter'
+ }
+ }
+];
+
+$result_errors{'button_replacement_direction_strings_customization'} = [];
+
+
+$result_floats{'button_replacement_direction_strings_customization'} = {};
+
+
+1;
diff --git
a/tp/t/results/init_files_tests/button_replacement_direction_strings_customization/res_html/chapter.html
b/tp/t/results/init_files_tests/button_replacement_direction_strings_customization/res_html/chapter.html
new file mode 100644
index 0000000000..c7bbeb4a33
--- /dev/null
+++
b/tp/t/results/init_files_tests/button_replacement_direction_strings_customization/res_html/chapter.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>chapter (top)</title>
+
+<meta name="description" content="chapter (top)">
+<meta name="keywords" content="chapter (top)">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+<link href="index.html" rel="start" title="Top">
+<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
+<link href="index.html" rel="up" title="Top">
+<link href="index.html" rel="prev" title="Top">
+<style type="text/css">
+<!--
+a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
+span:hover a.copiable-link {visibility: visible}
+-->
+</style>
+
+
+</head>
+
+<body lang="en">
+<div class="chapter-level-extent" id="chapter">
+<div class="nav-panel">
+<p>
+Previous: <a href="index.html" accesskey="p" rel="prev">top</a>, Up: <a
href="index.html" accesskey="u" rel="up">top</a> [<a
href="index.html#SEC_Contents" title="The Main Table Description" accesskey="t"
rel="contents">THE &mdash Table</a>]</p>
+</div>
+<hr>
+<h2 class="chapter" id="chap"><span>1 chap<a class="copiable-link"
href="#chap"> ¶</a></span></h2>
+</div>
+
+
+
+</body>
+</html>
diff --git
a/tp/t/results/init_files_tests/button_replacement_direction_strings_customization/res_html/index.html
b/tp/t/results/init_files_tests/button_replacement_direction_strings_customization/res_html/index.html
new file mode 100644
index 0000000000..c71105a6f6
--- /dev/null
+++
b/tp/t/results/init_files_tests/button_replacement_direction_strings_customization/res_html/index.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>Top (top)</title>
+
+<meta name="description" content="Top (top)">
+<meta name="keywords" content="Top (top)">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+<link href="#Top" rel="start" title="Top">
+<link href="#SEC_Contents" rel="contents" title="Table of Contents">
+<link href="chapter.html" rel="next" title="chapter">
+<style type="text/css">
+<!--
+a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
+span:hover a.copiable-link {visibility: visible}
+ul.toc-numbered-mark {list-style: none}
+-->
+</style>
+
+
+</head>
+
+<body lang="en">
+
+<div class="top-level-extent" id="Top">
+<div class="nav-panel">
+<p>
+Next: <a href="chapter.html" accesskey="n" rel="next">chap</a> [<a
href="#SEC_Contents" title="The Main Table Description" accesskey="t"
rel="contents">THE &mdash Table</a>]</p>
+</div>
+<hr>
+<h1 class="top" id="top"><span>top<a class="copiable-link" href="#top">
¶</a></span></h1>
+
+<div class="region-contents" id="SEC_Contents">
+<h2 class="contents-heading">Table of Contents</h2>
+
+<div class="contents">
+
+<ul class="toc-numbered-mark">
+ <li><a id="toc-chap" href="chapter.html">1 chap</a></li>
+</ul>
+</div>
+</div>
+</div>
+<hr>
+<div class="nav-panel">
+<p>
+Next: <a href="chapter.html" accesskey="n" rel="next">chap</a> [<a
href="#SEC_Contents" title="The Main Table Description" accesskey="t"
rel="contents">THE &mdash Table</a>]</p>
+</div>
+
+
+
+</body>
+</html>