[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Tue, 9 Jan 2024 08:08:17 -0500 (EST) |
branch: master
commit b15425c7531bd14af0577f306823225eb54422ae
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Jan 8 21:53:55 2024 +0100
* tp/Texinfo/Convert/Converter.pm (converter),
tp/Texinfo/Convert/LaTeX.pm (converter_initialize),
tp/Texinfo/Convert/Plaintext.pm (converter_initialize): set
'convert_text_options' conversion to text options state with
copy_options_for_convert_text, to be used in converters instead of
calling copy_options_for_convert_text each time conversion to text
options are needed. Remove the equivalent code from specific
converters.
* tp/Texinfo/Convert/Text.pm (set_options_code, reset_options_code)
(set_options_encoding_if_not_ascii, set_options_encoding)
(reset_options_encoding, convert_to_text),
tp/Texinfo/XS/main/get_perl_info.c (copy_sv_options_for_convert_text):
add functions to modify the conversion to text options without redoing
the whole options hash. Do not use 'code' in text options to set
code, only set_options_code().
* tp/Texinfo/Convert/DocBook.pm, tp/Texinfo/Convert/HTML.pm,
tp/Texinfo/Convert/IXIN.pm, tp/Texinfo/Convert/Info.pm,
tp/Texinfo/Convert/LaTeX.pm, tp/Texinfo/Convert/Plaintext.pm,
tp/Texinfo/Convert/TexinfoMarkup.pm,
tp/Texinfo/Convert/TextContent.pm, tp/Texinfo/Structuring.pm,
tp/ext/epub3.pm, tp/ext/highlight_syntax.pm, tp/init/chm.pm: do not
use copy_options_for_convert_text in converters, instead use converter
'convert_text_options' and modify it and reset it with the
set_options_* and reset_options_* new functions of
Texinfo/Convert/Text.pm.
---
ChangeLog | 30 +++++++++++++++++
tp/Texinfo/Convert/Converter.pm | 4 +++
tp/Texinfo/Convert/DocBook.pm | 65 ++++++++++++++++++++++++-------------
tp/Texinfo/Convert/HTML.pm | 65 +++++++++++++++++++++++++------------
tp/Texinfo/Convert/IXIN.pm | 26 +++++++++++----
tp/Texinfo/Convert/Info.pm | 23 ++++++++-----
tp/Texinfo/Convert/LaTeX.pm | 55 +++++++++++++++++++------------
tp/Texinfo/Convert/Plaintext.pm | 11 ++++---
tp/Texinfo/Convert/TexinfoMarkup.pm | 27 +++++++++++----
tp/Texinfo/Convert/Text.pm | 55 +++++++++++++++++++++++++++++--
tp/Texinfo/Convert/TextContent.pm | 3 +-
tp/Texinfo/Structuring.pm | 9 +++--
tp/Texinfo/XS/main/get_perl_info.c | 8 ++---
tp/ext/epub3.pm | 23 ++++++-------
tp/ext/highlight_syntax.pm | 8 +++--
tp/init/chm.pm | 19 ++++++-----
16 files changed, 310 insertions(+), 121 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index aae9d14e55..8395b0f362 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2024-01-08 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/Converter.pm (converter),
+ tp/Texinfo/Convert/LaTeX.pm (converter_initialize),
+ tp/Texinfo/Convert/Plaintext.pm (converter_initialize): set
+ 'convert_text_options' conversion to text options state with
+ copy_options_for_convert_text, to be used in converters instead of
+ calling copy_options_for_convert_text each time conversion to text
+ options are needed. Remove the equivalent code from specific
+ converters.
+
+ * tp/Texinfo/Convert/Text.pm (set_options_code, reset_options_code)
+ (set_options_encoding_if_not_ascii, set_options_encoding)
+ (reset_options_encoding, convert_to_text),
+ tp/Texinfo/XS/main/get_perl_info.c (copy_sv_options_for_convert_text):
+ add functions to modify the conversion to text options without redoing
+ the whole options hash. Do not use 'code' in text options to set
+ code, only set_options_code().
+
+ * tp/Texinfo/Convert/DocBook.pm, tp/Texinfo/Convert/HTML.pm,
+ tp/Texinfo/Convert/IXIN.pm, tp/Texinfo/Convert/Info.pm,
+ tp/Texinfo/Convert/LaTeX.pm, tp/Texinfo/Convert/Plaintext.pm,
+ tp/Texinfo/Convert/TexinfoMarkup.pm,
+ tp/Texinfo/Convert/TextContent.pm, tp/Texinfo/Structuring.pm,
+ tp/ext/epub3.pm, tp/ext/highlight_syntax.pm, tp/init/chm.pm: do not
+ use copy_options_for_convert_text in converters, instead use converter
+ 'convert_text_options' and modify it and reset it with the
+ set_options_* and reset_options_* new functions of
+ Texinfo/Convert/Text.pm.
+
2024-01-08 Patrice Dumas <pertusus@free.fr>
* tp/t/accents.t: initialize converter with
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 81b1a5cb50..1f6f7a7f0c 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -331,6 +331,10 @@ sub converter($;$)
$converter->converter_initialize();
+ $converter->{'convert_text_options'}
+ = {Texinfo::Convert::Text::copy_options_for_convert_text($converter)};
+
+
return $converter;
}
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index 56ebfe6687..3f13b20a04 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -1264,10 +1264,18 @@ sub _convert($$;$)
if (defined($element->{'args'}->[0])
and $element->{'args'}->[0]->{'contents'}
and @{$element->{'args'}->[0]->{'contents'}}) {
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::set_options_encoding_if_not_ascii($self,
+ $self->{'convert_text_options'});
my $basefile = Texinfo::Convert::Text::convert_to_text(
- {'contents' => $element->{'args'}->[0]->{'contents'}},
- {'code' => 1,
- Texinfo::Convert::Text::copy_options_for_convert_text($self, 1)});
+ $element->{'args'}->[0],
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_encoding(
+ $self->{'convert_text_options'});
+
my $is_inline = Texinfo::Common::element_is_inline($element);
if ($is_inline) {
$result .= "<inlinemediaobject>";
@@ -1326,12 +1334,18 @@ sub _convert($$;$)
if (defined($element->{'args'}->[0])
and $element->{'args'}->[0]->{'contents'}
and @{$element->{'args'}->[0]->{'contents'}}) {
- $email = $element->{'args'}->[0]->{'contents'};
+ $email = $element->{'args'}->[0];
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::set_options_encoding_if_not_ascii($self,
+ $self->{'convert_text_options'});
$email_text
= $self->_protect_text(Texinfo::Convert::Text::convert_to_text(
- {'contents' => $email},
- {'code' => 1,
- Texinfo::Convert::Text::copy_options_for_convert_text($self,
1)}));
+ $email, $self->{'convert_text_options'}));
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_encoding(
+ $self->{'convert_text_options'});
}
if ($name and $email) {
return "<ulink url=\"mailto:$email_text\">"
@@ -1347,16 +1361,22 @@ sub _convert($$;$)
} elsif ($element->{'cmdname'} eq 'uref' or $element->{'cmdname'} eq
'url') {
if ($element->{'args'}) {
- my ($url_text, $url_content);
+ my ($url_text, $url_arg);
if (defined($element->{'args'}->[0])
and $element->{'args'}->[0]->{'contents'}
and @{$element->{'args'}->[0]->{'contents'}}) {
- $url_content = $element->{'args'}->[0]->{'contents'};
+ $url_arg = $element->{'args'}->[0];
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::set_options_encoding_if_not_ascii($self,
+ $self->{'convert_text_options'});
$url_text = $self->_protect_text(
- Texinfo::Convert::Text::convert_to_text(
- {'contents' => $url_content},
- {'code' => 1,
- Texinfo::Convert::Text::copy_options_for_convert_text($self,
1)}));
+ Texinfo::Convert::Text::convert_to_text($url_arg,
+ $self->{'convert_text_options'}));
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_encoding(
+ $self->{'convert_text_options'});
} else {
$url_text = '';
}
@@ -1365,16 +1385,14 @@ sub _convert($$;$)
and defined($element->{'args'}->[1])
and $element->{'args'}->[1]->{'contents'}
and @{$element->{'args'}->[1]->{'contents'}}) {
- $replacement = $self->_convert({'contents'
- => $element->{'args'}->[1]->{'contents'}});
+ $replacement = $self->_convert($element->{'args'}->[1]);
}
if (!defined($replacement) or $replacement eq '') {
if (scalar(@{$element->{'args'}}) == 3
and defined($element->{'args'}->[2])
and $element->{'args'}->[2]->{'contents'}
and @{$element->{'args'}->[2]->{'contents'}}) {
- $replacement = $self->_convert({'contents'
- => $element->{'args'}->[2]->{'contents'}});
+ $replacement = $self->_convert($element->{'args'}->[2]);
}
}
if (!defined($replacement) or $replacement eq '') {
@@ -1391,8 +1409,7 @@ sub _convert($$;$)
and defined($element->{'args'}->[0])
and $element->{'args'}->[0]->{'contents'}
and @{$element->{'args'}->[0]->{'contents'}}) {
- my $arg = $self->_convert({'contents'
- => $element->{'args'}->[0]->{'contents'}});
+ my $arg = $self->_convert($element->{'args'}->[0]);
if ($arg ne '') {
my $format_element;
if ($element->{'cmdname'} eq 'abbr') {
@@ -1543,10 +1560,14 @@ sub _convert($$;$)
if ($content->{'type'} and $content->{'type'} eq
'bracketed_arg') {
my $prototype_text = '';
if ($content->{'contents'}) {
+ Texinfo::Convert::Text::set_options_encoding_if_not_ascii(
+ $self, $self->{'convert_text_options'});
$prototype_text
= Texinfo::Convert::Text::convert_to_text(
{'contents' => $content->{'contents'}},
- {Texinfo::Convert::Text::copy_options_for_convert_text($self, 1)});
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_encoding(
+ $self->{'convert_text_options'});
}
push @fractions,
Texinfo::Convert::Unicode::string_width($prototype_text);
@@ -1585,8 +1606,8 @@ sub _convert($$;$)
and @{$element->{'args'}->[0]->{'contents'}}) {
my $quotation_arg_text
= Texinfo::Convert::Text::convert_to_text(
- $element->{'args'}->[0],
- {Texinfo::Convert::Text::copy_options_for_convert_text($self)});
+ $element->{'args'}->[0],
+ $self->{'convert_text_options'});
if ($docbook_special_quotations{lc($quotation_arg_text)}) {
$format_element = lc($quotation_arg_text);
} else {
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 44d362bbae..f98c9a3ec5 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -7515,7 +7515,7 @@ sub _convert_def_line_type($$$$)
# should probably never happen
return &{$self->formatting_function('format_protect_text')}($self,
Texinfo::Convert::Text::convert_to_text(
- $element,
{Texinfo::Convert::Text::copy_options_for_convert_text($self)}));
+ $element, $self->{'convert_text_options'}));
}
my $index_label = '';
@@ -10571,10 +10571,11 @@ sub _external_node_href($$$)
# used if $target_split
my $directory = '';
if ($external_node->{'extra'}->{'manual_content'}) {
+ Texinfo::Convert::Text::set_options_code($self->{'convert_text_options'});
my $manual_name = Texinfo::Convert::Text::convert_to_text(
- $external_node->{'extra'}->{'manual_content'},
- { 'code' => 1,
- Texinfo::Convert::Text::copy_options_for_convert_text($self)});
+ $external_node->{'extra'}->{'manual_content'},
+ $self->{'convert_text_options'});
+
Texinfo::Convert::Text::reset_options_code($self->{'convert_text_options'});
if ($self->get_conf('IGNORE_REF_TO_TOP_NODE_UP') and $target eq '') {
my $top_node_up = $self->get_conf('TOP_NODE_UP');
if (defined($top_node_up) and "($manual_name)" eq $top_node_up) {
@@ -11866,7 +11867,7 @@ sub output_internal_links($)
my $tree = $self->command_tree($command);
if ($tree) {
$text = Texinfo::Convert::Text::convert_to_text($tree,
- {Texinfo::Convert::Text::copy_options_for_convert_text($self)});
+ $self->{'convert_text_options'});
}
}
if (defined($href) or defined($text)) {
@@ -11879,14 +11880,10 @@ sub output_internal_links($)
}
my $index_entries_by_letter = $self->get_info('index_entries_by_letter');
if ($index_entries_by_letter) {
- my %options = Texinfo::Convert::Text::copy_options_for_convert_text($self);
foreach my $index_name (sort(keys (%{$index_entries_by_letter}))) {
foreach my $letter_entry (@{$index_entries_by_letter->{$index_name}}) {
foreach my $index_entry (@{$letter_entry->{'entries'}}) {
my $main_entry_element = $index_entry->{'entry_element'};
- my $in_code
- = $self->{'indices_information'}->{$index_entry->{'index_name'}}
- ->{'in_code'};
# does not refer to the document
next if ($main_entry_element->{'extra'}
and ($main_entry_element->{'extra'}->{'seeentry'}
@@ -11894,8 +11891,13 @@ sub output_internal_links($)
my $href;
$href = $self->command_href($main_entry_element, '');
# Obtain term by converting to text
- my $converter_options = {%options};
- $converter_options->{'code'} = $in_code;
+ my $in_code
+ = $self->{'indices_information'}->{$index_entry->{'index_name'}}
+ ->{'in_code'};
+ if ($in_code) {
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
+ }
my $entry_reference_content_element
= Texinfo::Common::index_content_element($main_entry_element);
my @contents = ($entry_reference_content_element);
@@ -11905,7 +11907,12 @@ sub output_internal_links($)
push @contents, @{$subentries_tree->{'contents'}};
}
my $index_term = Texinfo::Convert::Text::convert_to_text(
- {'contents' => \@contents}, $converter_options);
+ {'contents' => \@contents},
+ $self->{'convert_text_options'});
+ if ($in_code) {
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
+ }
if (defined($index_term) and $index_term =~ /\S/) {
$out_string .= $href if (defined($href));
$out_string .= "\t$index_name\t";
@@ -12107,7 +12114,7 @@ sub _prepare_converted_output_info($)
if ($self->{'global_commands'}->{'copying'}) {
my $copying_comment = Texinfo::Convert::Text::convert_to_text(
{'contents' => $self->{'global_commands'}->{'copying'}->{'contents'}},
- {Texinfo::Convert::Text::copy_options_for_convert_text($self)});
+ $self->{'convert_text_options'});
if ($copying_comment ne '') {
$self->{'copying_comment'}
= &{$self->formatting_function('format_comment')}($self,
$copying_comment);
@@ -13070,25 +13077,41 @@ sub _convert($$;$)
_pop_code_context($self);
$self->_pop_document_context();
} elsif ($arg_type eq 'monospacetext') {
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
$arg_formatted->{$arg_type}
= Texinfo::Convert::Text::convert_to_text($arg,
- {'code' => 1,
-
Texinfo::Convert::Text::copy_options_for_convert_text($self)});
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
} elsif ($arg_type eq 'filenametext') {
+
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
# Always use encoded characters for file names
+
Texinfo::Convert::Text::set_options_encoding_if_not_ascii($self,
+ $self->{'convert_text_options'});
$arg_formatted->{$arg_type}
= Texinfo::Convert::Text::convert_to_text($arg,
- {'code' => 1,
- Texinfo::Convert::Text::copy_options_for_convert_text($self,
1)});
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_encoding(
+ $self->{'convert_text_options'});
} elsif ($arg_type eq 'url') {
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
# set the encoding to UTF-8 to always have a string that is
suitable
# for percent encoding.
- my $text_conversion_options = {'code' => 1,
- Texinfo::Convert::Text::copy_options_for_convert_text($self,
1)};
- $text_conversion_options->{'enabled_encoding'} = 'utf-8';
+ Texinfo::Convert::Text::set_options_encoding(
+ $self->{'convert_text_options'}, 'utf-8');
$arg_formatted->{$arg_type}
= Texinfo::Convert::Text::convert_to_text($arg,
- $text_conversion_options);
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_encoding(
+ $self->{'convert_text_options'});
} elsif ($arg_type eq 'raw') {
_set_raw_context($self);
$arg_formatted->{$arg_type} = $self->_convert($arg,
$explanation);
diff --git a/tp/Texinfo/Convert/IXIN.pm b/tp/Texinfo/Convert/IXIN.pm
index 6552719c12..a1b71ff902 100644
--- a/tp/Texinfo/Convert/IXIN.pm
+++ b/tp/Texinfo/Convert/IXIN.pm
@@ -892,20 +892,34 @@ sub output_ixin($$)
if (defined($command->{'args'}->[0])
and $command->{'args'}->[0]->{'contents'}
and @{$command->{'args'}->[0]->{'contents'}}) {
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::set_options_encoding_if_not_ascii($self,
+ $self->{'convert_text_options'});
$basefile = Texinfo::Convert::Text::convert_to_text(
- {'contents' => $command->{'args'}->[0]->{'contents'}},
- {'code' => 1,
- Texinfo::Convert::Text::copy_options_for_convert_text($self, 1)});
+ $command->{'args'}->[0],
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_encoding(
+ $self->{'convert_text_options'});
} else {
next;
}
if (defined($command->{'args'}->[4])
and $command->{'args'}->[4]->{'contents'}
and @{$command->{'args'}->[4]->{'contents'}}) {
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::set_options_encoding_if_not_ascii($self,
+ $self->{'convert_text_options'});
$extension = Texinfo::Convert::Text::convert_to_text(
- {'contents' => $command->{'args'}->[4]->{'contents'}},
- {'code' => 1,
- Texinfo::Convert::Text::copy_options_for_convert_text($self, 1)});
+ $command->{'args'}->[4],
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_encoding(
+ $self->{'convert_text_options'});
$extension =~ s/^\.//;
@extension = ($extension);
}
diff --git a/tp/Texinfo/Convert/Info.pm b/tp/Texinfo/Convert/Info.pm
index a859bb88c9..04de6372de 100644
--- a/tp/Texinfo/Convert/Info.pm
+++ b/tp/Texinfo/Convert/Info.pm
@@ -563,17 +563,24 @@ sub format_image($$)
if (defined($element->{'args'}->[0])
and $element->{'args'}->[0]->{'contents'}
and @{$element->{'args'}->[0]->{'contents'}}) {
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
my $basefile = Texinfo::Convert::Text::convert_to_text(
- {'contents' => $element->{'args'}->[0]->{'contents'}},
- {'code' => 1,
- Texinfo::Convert::Text::copy_options_for_convert_text($self)});
+ $element->{'args'}->[0],
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
+
if (defined($element->{'args'}->[4])
and $element->{'args'}->[4]->{'contents'}
and @{$element->{'args'}->[4]->{'contents'}}) {
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
my $extension = Texinfo::Convert::Text::convert_to_text(
- {'contents' => $element->{'args'}->[4]->{'contents'}},
- {'code' => 1,
- Texinfo::Convert::Text::copy_options_for_convert_text($self)});
+ $element->{'args'}->[4],
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
unshift @extensions, ".$extension";
unshift @extensions, "$extension";
}
@@ -598,8 +605,8 @@ sub format_image($$)
and $element->{'args'}->[3]->{'contents'}
and @{$element->{'args'}->[3]->{'contents'}}) {
$alt = Texinfo::Convert::Text::convert_to_text(
- {'contents' => $element->{'args'}->[3]->{'contents'}},
- {Texinfo::Convert::Text::copy_options_for_convert_text($self)});
+ $element->{'args'}->[3],
+ $self->{'convert_text_options'});
}
my $result;
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 57fc65b6ab..638e3d5504 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -843,12 +843,6 @@ sub converter_initialize($)
}
%{$self->{'quotes_map'}} = %quotes_map;
- # for file names
- $self->{'convert_encoded_text_options'}
- = {Texinfo::Convert::Text::copy_options_for_convert_text($self, 1)};
- # for other conversions to text
- $self->{'convert_text_options'}
- = {Texinfo::Convert::Text::copy_options_for_convert_text($self)};
# this condition means that there is no way to turn off
# @U expansion to utf-8 characters even though this
@@ -2452,7 +2446,10 @@ sub _index_entry($$)
pop @{$self->{'formatting_context'}->[-1]->{'code'}};
}
# always setup a string to sort with as we may use commands
- $self->{'index_formatting_text_options'}->{'code'} = $in_code;
+ if ($in_code) {
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'index_formatting_text_options'});
+ }
my $sort_string
= Texinfo::Structuring::index_entry_element_sort_string(
$self, $entry,
@@ -2467,6 +2464,8 @@ sub _index_entry($$)
$result = _protect_index_text($result).'@';
}
if ($in_code) {
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'index_formatting_text_options'});
$result .= "\\texttt{" . _protect_index_text($index_entry) . "}";
} else {
$result .= _protect_index_text($index_entry);
@@ -2962,9 +2961,17 @@ sub _convert($$)
and @{$element->{'args'}->[0]->{'contents'}}) {
# distinguish text basefile used to find the file and
# converted basefile with special characters escaped
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::set_options_encoding_if_not_ascii($self,
+ $self->{'convert_text_options'});
my $basefile = Texinfo::Convert::Text::convert_to_text(
- {'contents' => $element->{'args'}->[0]->{'contents'}},
- {'code' => 1, %{$self->{'convert_encoded_text_options'}}});
+ $element->{'args'}->[0],
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_encoding(
+ $self->{'convert_text_options'});
# warn if no file is found, even though the basefile is used
# in any case.
@@ -3050,7 +3057,7 @@ sub _convert($$)
if ($element->{'args'}) {
my $name;
my $converted_name;
- my $email;
+ my $email_arg;
my $email_text;
if (scalar (@{$element->{'args'}}) == 2
and defined($element->{'args'}->[1])
@@ -3062,15 +3069,19 @@ sub _convert($$)
if (defined($element->{'args'}->[0])
and $element->{'args'}->[0]->{'contents'}
and @{$element->{'args'}->[0]->{'contents'}}) {
- $email = $element->{'args'}->[0]->{'contents'};
+ $email_arg = $element->{'args'}->[0];
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
$email_text
= $self->_protect_url(Texinfo::Convert::Text::convert_to_text(
- {'contents' => $email},
- {'code' => 1, %{$self->{'convert_text_options'}}}));
+ $email_arg,
+ $self->{'convert_text_options'}));
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
}
- if ($name and $email) {
+ if ($name and $email_arg) {
$result .= "\\href{mailto:$email_text}{$converted_name}";
- } elsif ($email) {
+ } elsif ($email_arg) {
$result .= "\\href{mailto:$email_text}{\\nolinkurl{$email_text}}";
} elsif ($name) {
$result .= $converted_name;
@@ -3088,17 +3099,19 @@ sub _convert($$)
} elsif ($element->{'args'}->[0]
and $element->{'args'}->[0]->{'contents'}
and @{$element->{'args'}->[0]->{'contents'}}) {
- my $url_content = $element->{'args'}->[0]->{'contents'};
+ my $url_content = $element->{'args'}->[0];
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
my $url_text = $self->_protect_url(
- Texinfo::Convert::Text::convert_to_text(
- {'contents' => $url_content},
- {'code' => 1, %{$self->{'convert_text_options'}}}));
+ Texinfo::Convert::Text::convert_to_text($url_content,
+ $self->{'convert_text_options'}));
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
if (scalar(@{$element->{'args'}}) == 2
and defined($element->{'args'}->[1])
and $element->{'args'}->[1]->{'contents'}
and @{$element->{'args'}->[1]->{'contents'}}) {
- my $description = _convert($self, {'contents',
- $element->{'args'}->[1]->{'contents'}});
+ my $description = _convert($self, $element->{'args'}->[1]);
my $text = $self->gdt_string('{text} ({url})',
{'text' => $description, 'url' => "\\nolinkurl{$url_text}"});
$result .= "\\href{$url_text}{$text}";
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 36fd737c78..7c393f0946 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -528,9 +528,6 @@ sub converter_initialize($)
$self->{'output_encoding_name'} = $self->get_conf('OUTPUT_ENCODING_NAME');
$self->{'debug'} = $self->get_conf('DEBUG');
- $self->{'convert_text_options'}
- = {Texinfo::Convert::Text::copy_options_for_convert_text($self)};
-
return $self;
}
@@ -1664,9 +1661,13 @@ sub format_image($$)
if (defined($element->{'args'}->[0])
and $element->{'args'}->[0]->{'contents'}
and @{$element->{'args'}->[0]->{'contents'}}) {
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
my $basefile = Texinfo::Convert::Text::convert_to_text(
- $element->{'args'}->[0],
- {'code' => 1, %{$self->{'convert_text_options'}}});
+ $element->{'args'}->[0],
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
my ($text, $width) = $self->txt_image_text($element, $basefile);
# remove last end of line
chomp($text) if (defined($text));
diff --git a/tp/Texinfo/Convert/TexinfoMarkup.pm
b/tp/Texinfo/Convert/TexinfoMarkup.pm
index 4c3a659185..3b3edcaf48 100644
--- a/tp/Texinfo/Convert/TexinfoMarkup.pm
+++ b/tp/Texinfo/Convert/TexinfoMarkup.pm
@@ -1208,18 +1208,33 @@ sub _convert($$;$)
if (defined($element->{'args'}->[$manual_arg_index])
and $element->{'args'}->[$manual_arg_index]->{'contents'}
and @{$element->{'args'}->[$manual_arg_index]->{'contents'}}) {
- $manual = Texinfo::Convert::Text::convert_to_text({'contents'
- => $element->{'args'}->[$manual_arg_index]->{'contents'}},
- {'code' => 1,
- Texinfo::Convert::Text::copy_options_for_convert_text($self,
1)});
+
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::set_options_encoding_if_not_ascii($self,
+ $self->{'convert_text_options'});
+ $manual = Texinfo::Convert::Text::convert_to_text(
+ $element->{'args'}->[$manual_arg_index],
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_encoding(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
}
if (!defined($manual) and $node_arg
and $node_arg->{'extra'}
and $node_arg->{'extra'}->{'manual_content'}) {
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::set_options_encoding_if_not_ascii($self,
+ $self->{'convert_text_options'});
$manual = Texinfo::Convert::Text::convert_to_text(
$node_arg->{'extra'}->{'manual_content'},
- {'code' => 1,
- Texinfo::Convert::Text::copy_options_for_convert_text($self,
1)});
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_encoding(
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
}
if (defined($manual)) {
my $manual_base = $manual;
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 17082d1881..ec80099f04 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -422,6 +422,58 @@ sub copy_options_for_convert_text($;$)
return %options;
}
+sub set_options_code($)
+{
+ my $options = shift;
+ $options->{'_code_state'}++;
+}
+
+sub reset_options_code($)
+{
+ my $options = shift;
+ $options->{'_code_state'}--;
+}
+
+sub set_options_encoding_if_not_ascii($$)
+{
+ my $self = shift;
+ my $options = shift;
+ my $output_encoding_name = $self->get_conf('OUTPUT_ENCODING_NAME');
+ if (defined($output_encoding_name)
+ and $output_encoding_name ne 'us-ascii') {
+ if (defined($options->{'_saved_enabled_encoding'})) {
+ print STDERR "BUG: if_not_ascii _saved_enabled_encoding set: "
+ .$options->{'_saved_enabled_encoding'}." / ".
+ $output_encoding_name ."\n";
+ #cluck();
+ }
+ $options->{'_saved_enabled_encoding'} = $options->{'enabled_encoding'};
+ $options->{'enabled_encoding'} = $output_encoding_name;
+ }
+}
+
+sub set_options_encoding($$)
+{
+ my $options = shift;
+ my $encoding = shift;
+ if (defined($options->{'_saved_enabled_encoding'})) {
+ print STDERR "BUG: _saved_enabled_encoding set: "
+ .$options->{'_saved_enabled_encoding'}."\n";
+ }
+ $options->{'_saved_enabled_encoding'} = $options->{'enabled_encoding'};
+ $options->{'enabled_encoding'} = $encoding;
+}
+
+sub reset_options_encoding($)
+{
+ my $options = shift;
+ if (defined($options->{'_saved_enabled_encoding'})) {
+ $options->{'enabled_encoding'} = $options->{'_saved_enabled_encoding'};
+ delete $options->{'_saved_enabled_encoding'};
+ }
+}
+
+
# Will never be called, used for the override.
sub _convert_tree_with_XS($$)
{
@@ -446,9 +498,6 @@ sub convert_to_text($;$)
confess("convert_to_text options not a ref\n");
}
bless $options;
- if ($options->{'code'}) {
- $options->{'_code_state'} = 1;
- }
}
# Interface with XS converter.
diff --git a/tp/Texinfo/Convert/TextContent.pm
b/tp/Texinfo/Convert/TextContent.pm
index 26c9c35110..e2abc572d0 100644
--- a/tp/Texinfo/Convert/TextContent.pm
+++ b/tp/Texinfo/Convert/TextContent.pm
@@ -141,9 +141,8 @@ sub _convert($$)
} elsif
(defined($Texinfo::Convert::Text::text_brace_no_arg_commands{$element->{'cmdname'}}))
{
return Texinfo::Convert::Text::brace_no_arg_command($element, undef);
} elsif ($Texinfo::Commands::accent_commands{$element->{'cmdname'}}) {
- my %options =
Texinfo::Convert::Text::copy_options_for_convert_text($self);
my $result = Texinfo::Convert::Text::text_accents($element,
- $options{'enabled_encoding'});
+ $self->{'convert_text_options'}->{'enabled_encoding'});
return $result;
}
}
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index bb92d614e7..94a9c20af9 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -2478,8 +2478,10 @@ sub setup_sortable_index_entries($$$$$;$)
foreach my $index_entry (@{$index_entries->{$index_name}}) {
my $entry_index_name = $index_entry->{'index_name'};
my $main_entry_element = $index_entry->{'entry_element'};
- $convert_text_options->{'code'}
- = $indices_information->{$entry_index_name}->{'in_code'};
+ my $in_code = $indices_information->{$entry_index_name}->{'in_code'};
+ if ($in_code) {
+ Texinfo::Convert::Text::set_options_code($convert_text_options);
+ }
my ($entry_key, $sort_entry_key)
= _index_entry_element_sort_string_key($customization_information,
$index_entry, $main_entry_element,
@@ -2551,6 +2553,9 @@ sub setup_sortable_index_entries($$$$$;$)
last;
}
}
+ if ($in_code) {
+ Texinfo::Convert::Text::reset_options_code($convert_text_options);
+ }
$index_entries_sort_strings->{$index_entry} = join(', ', @entry_keys);
}
$index_sortable_index_entries->{$index_name} = $sortable_index_entries;
diff --git a/tp/Texinfo/XS/main/get_perl_info.c
b/tp/Texinfo/XS/main/get_perl_info.c
index 373a7b9fb8..20f6603aea 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -917,7 +917,7 @@ TEXT_OPTIONS *
copy_sv_options_for_convert_text (SV *sv_in)
{
HV *hv_in;
- SV **code_sv;
+ SV **_code_state_sv;
SV **TEST_sv;
SV **INCLUDE_DIRECTORIES_sv;
SV **converter_sv;
@@ -941,9 +941,9 @@ copy_sv_options_for_convert_text (SV *sv_in)
if (enabled_encoding_sv)
text_options->encoding = strdup (SvPVutf8_nolen (*enabled_encoding_sv));
- FETCH(code)
- if (code_sv)
- text_options->code_state = SvIV (*code_sv);
+ FETCH(_code_state)
+ if (_code_state_sv)
+ text_options->code_state = SvIV (*_code_state_sv);
FETCH(INCLUDE_DIRECTORIES)
if (INCLUDE_DIRECTORIES_sv)
diff --git a/tp/ext/epub3.pm b/tp/ext/epub3.pm
index a3fe032d7d..6f5e538114 100644
--- a/tp/ext/epub3.pm
+++ b/tp/ext/epub3.pm
@@ -214,18 +214,19 @@ my %epub_js_extensions_mimetypes = (
'.css', 'text/css',
);
-sub _epub_convert_tree_to_text($$;$)
+sub _epub_convert_tree_to_text($$)
{
my $converter = shift;
my $tree = shift;
- my $options = shift;
- $options = {} if (!defined($options));
-
- return &{$converter->formatting_function('format_protect_text')}($converter,
- Texinfo::Convert::Text::convert_to_text($tree,
- {Texinfo::Convert::Text::copy_options_for_convert_text($converter, 1),
- %$options}));
+ Texinfo::Convert::Text::set_options_encoding_if_not_ascii($converter,
+ $converter->{'convert_text_options'});
+ my $result = &{$converter->formatting_function('format_protect_text')}(
+ $converter, Texinfo::Convert::Text::convert_to_text($tree,
+
$converter->{'convert_text_options'}));
+ Texinfo::Convert::Text::reset_options_encoding(
+ $converter->{'convert_text_options'});
+ return $result;
}
sub epub_noop($$)
@@ -459,7 +460,7 @@ sub epub_setup($)
$self->set_conf('EPUB_KEEP_CONTAINER_FOLDER', 1);
}
}
-
+
$epub_info_js_dir_name = undef;
if ($self->get_conf('INFO_JS_DIR')) {
# re-set INFO_JS_DIR up to have the javascript and
@@ -482,7 +483,7 @@ sub epub_setup($)
# determine main epub directory and directory for xhtml files,
# reset OUTFILE and SUBDIR to match with the epub directory
# for XHTML output
-
+
if (defined($self->get_conf('OUTFILE'))) {
$epub_outfile = $self->get_conf('OUTFILE');
# if not undef, will be used as directory name in
@@ -799,7 +800,7 @@ EOT
if ($element->{'extra'}->{'titlepage'}
and $element->{'args'}->[0]->{'contents'}) {
my $author_str = _epub_convert_tree_to_text($self,
- {'contents' => $element->{'args'}->[0]->{'contents'}});
+ $element->{'args'}->[0]);
if ($author_str =~ /\S/) {
push @authors, $author_str;
}
diff --git a/tp/ext/highlight_syntax.pm b/tp/ext/highlight_syntax.pm
index 2f48b18af5..1a03ec6b67 100644
--- a/tp/ext/highlight_syntax.pm
+++ b/tp/ext/highlight_syntax.pm
@@ -257,8 +257,12 @@ sub _convert_element($$)
and $tree->{'contents'}->[-1]->{'cmdname'} eq 'end') {
pop @{$tree->{'contents'}};
}
- my $text = Texinfo::Convert::Text::convert_to_text($tree, {'code' => 1,
- Texinfo::Convert::Text::copy_options_for_convert_text($self)});
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
+ my $text = Texinfo::Convert::Text::convert_to_text($tree,
+ $self->{'convert_text_options'});
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
# make sure that the text ends with a newline
chomp ($text);
$text .= "\n";
diff --git a/tp/init/chm.pm b/tp/init/chm.pm
index 7e7ad5cda1..6b1a9dd127 100644
--- a/tp/init/chm.pm
+++ b/tp/init/chm.pm
@@ -191,18 +191,14 @@ sub chm_noop($$)
return '';
}
-sub _chm_convert_tree_to_text($$;$)
+sub _chm_convert_tree_to_text($$)
{
my $converter = shift;
my $tree = shift;
- my $options = shift;
-
- $options = {} if (!defined($options));
return &{$converter->formatting_function('format_protect_text')}($converter,
Texinfo::Convert::Text::convert_to_text($tree,
- {Texinfo::Convert::Text::copy_options_for_convert_text($converter),
- %$options}));
+ $converter->{'convert_text_options'}));
}
sub chm_init($)
@@ -263,9 +259,16 @@ sub chm_init($)
my $in_code = 0;
$in_code = 1
if
($indices_information->{$index_entry_ref->{'index_name'}}->{'in_code'});
+ if ($in_code) {
+ Texinfo::Convert::Text::set_options_code(
+ $self->{'convert_text_options'});
+ }
my $entry = _chm_convert_tree_to_text($self,
- {'contents' => [$entry_content_element]},
- {'code' => $in_code});
+ $entry_content_element);
+ if ($in_code) {
+ Texinfo::Convert::Text::reset_options_code(
+ $self->{'convert_text_options'});
+ }
print $hhk_fh "<LI> <OBJECT type=\"text/sitemap\">\n"
."<param name=\"Name\" value=\"$entry\">\n"
."<param name=\"Local\" value=\"$origin_href\">\n"
- master updated (ae85f7133c -> 03c9181681), Patrice Dumas, 2024/01/09
- [no subject], Patrice Dumas, 2024/01/09
- [no subject],
Patrice Dumas <=
- [no subject], Patrice Dumas, 2024/01/09
- [no subject], Patrice Dumas, 2024/01/09
- [no subject], Patrice Dumas, 2024/01/09
- [no subject], Patrice Dumas, 2024/01/09
- [no subject], Patrice Dumas, 2024/01/09
- [no subject], Patrice Dumas, 2024/01/09