[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp Texinfo/Convert/Text.pm t/accents.t
From: |
Patrice Dumas |
Subject: |
texinfo/tp Texinfo/Convert/Text.pm t/accents.t |
Date: |
Tue, 22 Mar 2011 19:34:56 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/03/22 19:34:55
Modified files:
tp/Texinfo/Convert: Text.pm
tp/t : accents.t
Log message:
Split _find_innermost_accent in 2, one gets a contents array, then it
is formatted, taking into account the current encoding.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Text.pm?cvsroot=texinfo&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/accents.t?cvsroot=texinfo&r1=1.9&r2=1.10
Patches:
Index: Texinfo/Convert/Text.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Text.pm,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- Texinfo/Convert/Text.pm 7 Mar 2011 00:22:20 -0000 1.32
+++ Texinfo/Convert/Text.pm 22 Mar 2011 19:34:55 -0000 1.33
@@ -563,16 +563,17 @@
$ignored_types{$type} = 1;
}
-# find the innermost accent and the correspponding text
-sub _find_innermost_accent($)
+# find the innermost accent and the correspponding text contents
+#Â FIXME This is not output dependent, move to Texinfo::Parser?
+sub _find_innermost_accent_contents($;$)
{
my $current = shift;
+ my $encoding = shift;
my @accent_commands = ();
- my $text = '';
- my $done = 0;
my $debug = 0;
ACCENT:
while (1) {
+ #Â the following can happen if called with a bad tree
if (!$current->{'args'} or !$current->{'cmdname'}
or !$accent_commands{$current->{'cmdname'}}) {
print STDERR "BUG: Not an accent command in accent\n";
@@ -584,7 +585,7 @@
my $arg = $current->{'args'}->[0];
# a construct like @'e without content
if (defined($arg->{'text'})) {
- return ($arg->{'text'}, $current, address@hidden);
+ return ([$arg], $current, address@hidden);
}
if (!$arg->{'contents'}) {
print STDERR "BUG: No content in accent command\n";
@@ -593,29 +594,35 @@
last;
}
# inside the braces of an accent
+ my $text_contents = [];
foreach my $content (@{$arg->{'contents'}}) {
if (!($content->{'extra'} and $content->{'extra'}->{'invalid_nesting'})
and !($content->{'cmdname'} and ($content->{'cmdname'} eq 'c'
or $content->{'cmdname'} eq 'comment'))) {
- if (defined($content->{'text'})) {
- $text .= $content->{'text'};
- print STDERR "TEXT: $text\n" if ($debug);
- } elsif ($content->{'cmdname'} and
- defined($text_no_brace_commands{$content->{'cmdname'}})) {
- $text .= $text_no_brace_commands{$content->{'cmdname'}};
- print STDERR "NO BRACE COMMAND: $text\n" if ($debug);
- } elsif ($content->{'cmdname'} and
$text_brace_no_arg_commands{$content->{'cmdname'}}) {
- $text .= $text_brace_no_arg_commands{$content->{'cmdname'}};
- print STDERR "BRACE NO ARG COMMAND: $text\n" if ($debug);
- } else {
+ if ($content->{'cmdname'} and $accent_commands{$content->{'cmdname'}})
{
$current = $content;
next ACCENT;
+ } else {
+ push @$text_contents, $content;
}
}
}
- last;
+ #Â we go here if there was no nested accent
+ return ($text_contents, $current, address@hidden);
}
- return ($text, $current, address@hidden);
+}
+
+# find the innermost accent and format the correspponding text contents
+sub _find_innermost_accent($;$)
+{
+ my $current = shift;
+ my $encoding = shift;
+ my ($contents, $innermost_accent, $stack)
+ = _find_innermost_accent_contents($current);
+ my $options = {};
+ $options = {'enabled_encoding' => $encoding} if (defined($encoding));
+ return (convert({'contents' => $contents}, $options),
+ $innermost_accent, $stack);
}
# return the 8 bit, if it exists, and the unicode codepoint
@@ -647,7 +654,8 @@
my $debug;
#$debug = 1;
- my ($text, $innermost_accent, $stack) = _find_innermost_accent($current);
+ my ($text, $innermost_accent, $stack) = _find_innermost_accent($current,
+ $encoding);
print STDERR "INNERMOST: $innermost_accent->{'cmdname'}($text)\n"
if ($debug);
@@ -773,7 +781,8 @@
{
my $current = shift;
my $format_accents = shift;
- my ($result, $innermost_accent, $stack) = _find_innermost_accent($current);
+ my ($result, $innermost_accent, $stack) = _find_innermost_accent($current,
+ 'utf-8');
foreach my $accent_command (reverse(@$stack)) {
$result = Texinfo::Convert::Unicode::unicode_accent($result,
Index: t/accents.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/accents.t,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- t/accents.t 22 Mar 2011 00:37:04 -0000 1.9
+++ t/accents.t 22 Mar 2011 19:34:55 -0000 1.10
@@ -1,7 +1,7 @@
use strict;
use Test::More;
-BEGIN { plan tests => 21 };
+BEGIN { plan tests => 23 };
use lib '../texi2html/lib/Unicode-EastAsianWidth/lib/';
use lib '../texi2html/lib/libintl-perl/lib/';
@@ -34,7 +34,9 @@
['@address@hidden comment
e}', 'comment', 'e|~'],
['@~{@@}','no_brace_command', '@|~'],
- ['@address@hidden','no_brace_command', 'TeX|~'],
+ ['@address@hidden','brace_no_arg_command', 'TeX|~'],
+ ['@address@hidden@address@hidden','text_and_accent',
'i|~|^|dotless'],
+ ['@address@hidden@ringaccent b}}','two_accents', 'a|~|^'],
) {
test_accent_stack($test);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp Texinfo/Convert/Text.pm t/accents.t,
Patrice Dumas <=