[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sun, 29 Sep 2024 09:46:17 -0400 (EDT) |
branch: master
commit 783d6f383c828fa23245357ce3ddf8edde79819d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Jul 1 19:28:06 2024 +0200
* tp/Texinfo/Convert/DocBook.pm (_convert), tp/Texinfo/Convert/HTML.pm
(_convert_U_command), tp/Texinfo/Convert/LaTeX.pm (_convert),
tp/Texinfo/Convert/Plaintext.pm (_convert): reorganize slightly U
formatting code, simplify args conditions.
---
ChangeLog | 7 +++++++
tp/Texinfo/Convert/DocBook.pm | 16 +++++++-------
tp/Texinfo/Convert/HTML.pm | 6 +++---
tp/Texinfo/Convert/LaTeX.pm | 46 ++++++++++++++++++++---------------------
tp/Texinfo/Convert/Plaintext.pm | 44 +++++++++++++++++++--------------------
5 files changed, 60 insertions(+), 59 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index fb5f55f4db..f2eff41f5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-07-01 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/DocBook.pm (_convert), tp/Texinfo/Convert/HTML.pm
+ (_convert_U_command), tp/Texinfo/Convert/LaTeX.pm (_convert),
+ tp/Texinfo/Convert/Plaintext.pm (_convert): reorganize slightly U
+ formatting code, simplify args conditions.
+
2024-07-01 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/DocBook.pm (_convert): simplify conditions on
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index e557fac6ce..f133605a0d 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -1533,19 +1533,17 @@ sub _convert($$;$)
}
} elsif ($element->{'cmdname'} eq 'U') {
- my $argument_text;
if ($element->{'args'}
and $element->{'args'}->[0]->{'contents'}
and $element->{'args'}->[0]->{'contents'}->[0]->{'text'}) {
- $argument_text =
$element->{'args'}->[0]->{'contents'}->[0]->{'text'};
- }
- if ($argument_text) {
- $result = "&#x$argument_text;";
- } else {
- $result = '';
- }
- return $result;
+ my $arg_text = $element->{'args'}->[0]->{'contents'}->[0]->{'text'};
+ if (defined($arg_text)) {
+ my $result = "&#x$arg_text;";
+ return $result;
+ }
+ }
+ return '';
} elsif ($Texinfo::Commands::brace_commands{$element->{'cmdname'}} eq
'inline') {
my $expand = 0;
if ($Texinfo::Commands::inline_format_commands{$element->{'cmdname'}})
{
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index db91b9f30b..31e284844a 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -4232,10 +4232,10 @@ sub _convert_U_command($$$$)
my $args = shift;
if ($args and $args->[0]) {
- my $arg = $args->[0]->{'normal'};
- if ($arg ne '') {
+ my $arg_text = $args->[0]->{'normal'};
+ if ($arg_text ne '') {
# checks on the value already done in Parser, just output it here.
- return "&#x$arg;";
+ return "&#x$arg_text;";
}
}
return '';
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index e9e988232f..3f31ecedef 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -3757,36 +3757,34 @@ sub _convert($$)
$result .= _title_font($self, $element);
return $result;
} elsif ($cmdname eq 'U') {
- my $arg;
if ($element->{'args'}
- and $element->{'args'}->[0]
and $element->{'args'}->[0]->{'contents'}
- and $element->{'args'}->[0]->{'contents'}->[0]
and $element->{'args'}->[0]->{'contents'}->[0]->{'text'}) {
- $arg = $element->{'args'}->[0]->{'contents'}->[0]->{'text'};
- }
- if ($arg) {
- # Syntactic checks on the value were already done in Parser.pm,
- # but we have one more thing to test: since this is the one
- # place where we might output actual UTF-8 binary bytes, we have
- # to check that it is possible. If not, silently fall back to
- # plain text, on the theory that the user wants something.
- # Note that being able to output an unicode point as encoded
- # character does not mean that LaTeX will be able to process it.
- my $res;
- if ($self->{'to_utf8'}) {
- my $possible_conversion
- = Texinfo::Convert::Unicode::check_unicode_point_conversion($arg,
- $self->{'debug'});
- if ($possible_conversion) {
- $res = chr(hex($arg)); # ok to call chr
+ my $arg_text = $element->{'args'}->[0]->{'contents'}->[0]->{'text'};
+
+ if (defined($arg_text)) {
+ # Syntactic checks on the value were already done in Parser.pm,
+ # but we have one more thing to test: since this is the one
+ # place where we might output actual UTF-8 binary bytes, we have
+ # to check that it is possible. If not, silently fall back to
+ # plain text, on the theory that the user wants something.
+ # Note that being able to output an unicode point as encoded
+ # character does not mean that LaTeX will be able to process it.
+ my $res;
+ if ($self->{'to_utf8'}) {
+ my $possible_conversion
+ = Texinfo::Convert::Unicode::check_unicode_point_conversion(
+ $arg_text, $self->{'debug'});
+ if ($possible_conversion) {
+ $res = chr(hex($arg_text)); # ok to call chr
+ } else {
+ $res = "U+$arg_text";
+ }
} else {
- $res = "U+$arg";
+ $res = "U+$arg_text"; # not outputting UTF-8
}
- } else {
- $res = "U+$arg"; # not outputting UTF-8
+ $result .= _protect_text($self, $res);
}
- $result .= _protect_text($self, $res);
}
return $result;
} elsif ($cmdname eq 'value') {
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 2dc03ae37c..55c4c8462b 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -3199,35 +3199,33 @@ sub _convert($$)
_add_lines_count($self, 1);
return;
} elsif ($command eq 'U') {
- my $arg;
if ($element->{'args'}
- and $element->{'args'}->[0]
and $element->{'args'}->[0]->{'contents'}
- and $element->{'args'}->[0]->{'contents'}->[0]
and $element->{'args'}->[0]->{'contents'}->[0]->{'text'}) {
- $arg = $element->{'args'}->[0]->{'contents'}->[0]->{'text'};
- }
- if ($arg) {
- # Syntactic checks on the value were already done in Parser.pm,
- # but we have one more thing to test: since this is the one
- # place where we might output actual UTF-8 binary bytes, we have
- # to check that it is possible. If not, silently fall back to
- # plain text, on the theory that the user wants something.
- my $res;
- if ($self->{'to_utf8'}) {
- my $possible_conversion
- = Texinfo::Convert::Unicode::check_unicode_point_conversion($arg,
- $self->{'DEBUG'});
- if ($possible_conversion) {
- $res = chr(hex($arg)); # ok to call chr
+ my $arg_text = $element->{'args'}->[0]->{'contents'}->[0]->{'text'};
+
+ if (defined($arg_text)) {
+ # Syntactic checks on the value were already done in Parser.pm,
+ # but we have one more thing to test: since this is the one
+ # place where we might output actual UTF-8 binary bytes, we have
+ # to check that it is possible. If not, silently fall back to
+ # plain text, on the theory that the user wants something.
+ my $res;
+ if ($self->{'to_utf8'}) {
+ my $possible_conversion
+ = Texinfo::Convert::Unicode::check_unicode_point_conversion(
+ $arg_text, $self->{'DEBUG'});
+ if ($possible_conversion) {
+ $res = chr(hex($arg_text)); # ok to call chr
+ } else {
+ $res = "U+$arg_text";
+ }
} else {
- $res = "U+$arg";
+ $res = "U+$arg_text"; # not outputting UTF-8
}
- } else {
- $res = "U+$arg"; # not outputting UTF-8
+ _stream_output($self, add_text($formatter->{'container'}, $res),
+ $formatter->{'container'});
}
- _stream_output($self, add_text($formatter->{'container'}, $res),
- $formatter->{'container'});
}
return;
} elsif ($command eq 'value') {