texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

texinfo/tp TODO Texinfo/Common.pm Texinfo/Conve...


From: Patrice Dumas
Subject: texinfo/tp TODO Texinfo/Common.pm Texinfo/Conve...
Date: Sun, 21 Nov 2010 11:57:15 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        10/11/21 11:57:15

Modified files:
        tp             : TODO 
        tp/Texinfo     : Common.pm 
        tp/Texinfo/Convert: Line.pm Paragraph.pm Plaintext.pm 
        tp/t           : 03coverage_braces.t paragraph.t 

Log message:
        Handle @w better.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/TODO?cvsroot=texinfo&r1=1.54&r2=1.55
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Line.pm?cvsroot=texinfo&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Paragraph.pm?cvsroot=texinfo&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/03coverage_braces.t?cvsroot=texinfo&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/paragraph.t?cvsroot=texinfo&r1=1.8&r2=1.9

Patches:
Index: TODO
===================================================================
RCS file: /sources/texinfo/texinfo/tp/TODO,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -b -r1.54 -r1.55
--- TODO        9 Nov 2010 23:02:45 -0000       1.54
+++ TODO        21 Nov 2010 11:57:15 -0000      1.55
@@ -15,8 +15,6 @@
 
 test empty line in block or brace command in menu description.
 
-add protected spaces in Line.pm, and unit tests in paragraph.t.
-
 in hyphenation: only text and accent commands, and should
 only appear in toplevel
 

Index: Texinfo/Common.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Common.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- Texinfo/Common.pm   15 Nov 2010 00:22:36 -0000      1.2
+++ Texinfo/Common.pm   21 Nov 2010 11:57:15 -0000      1.3
@@ -225,6 +225,18 @@
 }
 
 
+# some classification to help converters
+our %ref_commands;
+foreach my $ref_command ('xref','ref','pxref','inforef') {
+  $ref_commands{$ref_command} = 1;
+}
+
+our %explained_commands;
+foreach my $explained_command ('abbr', 'acronym') {
+  $explained_commands{$explained_command} = 1;
+}
+
+
 # commands delimiting blocks, with an @end.
 # Value is either the number of arguments on the line separated by
 # commas or the type of command, 'raw', 'def' or 'multitable'.

Index: Texinfo/Convert/Line.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Line.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- Texinfo/Convert/Line.pm     21 Nov 2010 10:15:24 -0000      1.4
+++ Texinfo/Convert/Line.pm     21 Nov 2010 11:57:15 -0000      1.5
@@ -136,6 +136,28 @@
   $line->{'end_sentence'} = 0;
 }
 
+sub set_space_protection($$;$$)
+{
+  my $line = shift;
+  my $space_protection = shift;
+  my $ignore_columns = shift;
+  my $keep_end_lines = shift;
+  $line->{'protect_spaces'} = $space_protection 
+    if defined($space_protection);
+  $line->{'ignore_columns'} = $ignore_columns
+    if defined($ignore_columns);
+  # a no-op in fact
+  $line->{'keep_end_lines'} = $keep_end_lines
+    if defined($keep_end_lines);
+  # flush the spaces already existing
+  if ($space_protection) {
+    my $new_space = $line->{'space'};
+    $line->{'space'} = '';
+    return $new_space;
+  }
+  return '';
+}
+
 my $end_sentence_character = quotemeta('.?!');
 my $after_punctuation_characters = quotemeta('"\')]');
 
@@ -152,11 +174,15 @@
       $word = $line->{'word'} if (defined($line->{'word'}));
       print STDERR "s `$line->{'space'}', w `$word'\n";
     }
-    if ($text =~ s/^[^\S\n]+//) {
+    if ($text =~ s/^([^\S\n]+)//) {
+      my $spaces = $1;
       print STDERR "SPACES\n" if ($line->{'debug'});
       my $added_word = $line->{'word'};
       $result .= $line->add_pending_word();
-      if (!$line->{'begin'}) {
+      if ($line->{'protect_spaces'}) {
+        $result .= $spaces;
+        $line->{'space'} = '';
+      } elsif (!$line->{'begin'}) {
         if (!$line->{'frenchspacing'} and $line->{'end_sentence'}) {
           $line->{'space'} = '  ';
         } else {

Index: Texinfo/Convert/Paragraph.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Paragraph.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- Texinfo/Convert/Paragraph.pm        14 Nov 2010 21:30:26 -0000      1.6
+++ Texinfo/Convert/Paragraph.pm        21 Nov 2010 11:57:15 -0000      1.7
@@ -55,11 +55,17 @@
   print STDERR "para ($self->{'counter'}+$self->{'word_counter'}) word: $word, 
space `$self->{'space'}' end_sentence: $self->{'end_sentence'}\n"; 
 }
 
+sub _cut_line($)
+{
+  my $paragraph = shift;
+  return '' if ($paragraph->{'ignore_columns'});
+  return $paragraph->end_line();
+}
+
 # end a line.
 sub end_line($)
 {
   my $paragraph = shift;
-  return '' if ($paragraph->{'protected_spaces'});
   $paragraph->{'counter'} = 0;
   $paragraph->{'space'} = '';
   if (defined($paragraph->{'indent_length_next'})) {
@@ -134,7 +140,7 @@
     if ($paragraph->{'counter'} != 0 and 
         $paragraph->{'counter'} + $paragraph->{'word_counter'} + 
            length($paragraph->{'space'}) > $paragraph->{'max'}) {
-      $result .= $paragraph->end_line();
+      $result .= $paragraph->_cut_line();
     }
   }
   if (defined($space)) {
@@ -142,7 +148,7 @@
     $paragraph->{'space'} = $space;
     if ($paragraph->{'counter'} + length($paragraph->{'space'}) 
                     > $paragraph->{'max'}) {
-      $result .= $paragraph->end_line();
+      $result .= $paragraph->_cut_line();
     }
   }
   if (defined($end_sentence)) {
@@ -157,11 +163,18 @@
   $paragraph->{'end_sentence'} = 0;
 }
 
-sub set_space_protected($$)
+sub set_space_protection($$;$$)
 {
   my $paragraph = shift;
   my $space_protection = shift;
-  $paragraph->{'protected_spaces'} = $space_protection;
+  my $ignore_columns = shift;
+  my $keep_end_lines = shift;
+  $paragraph->{'protect_spaces'} = $space_protection 
+    if defined($space_protection);
+  $paragraph->{'ignore_columns'} = $ignore_columns
+    if defined($ignore_columns);
+  $paragraph->{'keep_end_lines'} = $keep_end_lines
+    if defined($keep_end_lines);
   # flush the spaces already existing
   if ($space_protection) {
     my $new_space = $paragraph->{'space'};
@@ -189,11 +202,12 @@
       print STDERR "($paragraph->{'counter'}+$paragraph->{'word_counter'}) s 
`$paragraph->{'space'}', w `$word'\n";
     }
     if ($text =~ s/^(\s+)//) {
+      my $spaces = $1;
       print STDERR "SPACES($paragraph->{'counter'})\n" if 
($paragraph->{'debug'});
       my $added_word = $paragraph->{'word'};
       $result .= $paragraph->add_pending_word();
-      if ($paragraph->{'protected_spaces'}) {
-        $paragraph->{'space'} .= $1;
+      if ($paragraph->{'protect_spaces'}) {
+        $paragraph->{'space'} .= $spaces;
         if ($paragraph->{'space'} =~ s/\n/ /g 
            and !$paragraph->{'frenchspacing'} and $paragraph->{'end_sentence'}
            and length($paragraph->{'space'}) < 2) {
@@ -214,6 +228,9 @@
       delete $paragraph->{'end_sentence'};
       if ($paragraph->{'counter'} + length($paragraph->{'space'}) 
                       > $paragraph->{'max'}) {
+        $result .= $paragraph->_cut_line();
+      }
+      if ($spaces =~ /\n/ and $paragraph->{'keep_end_lines'}) {
         $result .= $paragraph->end_line();
       }
     } elsif ($text =~ s/^(\p{Unicode::EastAsianWidth::InFullwidth})//) {
@@ -225,7 +242,7 @@
       if ($paragraph->{'counter'} != 0 and
           $paragraph->{'counter'} + $paragraph->{'word_counter'} 
                                > $paragraph->{'max'}) {
-        $result .= $paragraph->end_line();
+        $result .= $paragraph->_cut_line();
       }
       $result .= $paragraph->add_pending_word();
       delete $paragraph->{'end_sentence'};

Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- Texinfo/Convert/Plaintext.pm        20 Nov 2010 23:35:37 -0000      1.9
+++ Texinfo/Convert/Plaintext.pm        21 Nov 2010 11:57:15 -0000      1.10
@@ -79,10 +79,12 @@
 my %misc_commands = %Texinfo::Common::misc_commands;
 my %sectioning_commands = %Texinfo::Common::sectioning_commands;
 my %def_commands = %Texinfo::Common::def_commands;
+my %ref_commands = %Texinfo::Common::ref_commands;
 my %block_commands = %Texinfo::Common::block_commands;
 my %menu_commands = %Texinfo::Common::menu_commands;
 my %root_commands = %Texinfo::Common::root_commands;
 my %preformatted_commands = %Texinfo::Common::preformatted_commands;
+my %explained_commands = %Texinfo::Common::explained_commands;
 
 foreach my $def_command (keys(%def_commands)) {
   $kept_misc_commands{$def_command} = 1 if ($misc_commands{$def_command});
@@ -248,8 +250,9 @@
     $converter->{$key} = $defaults{$key} if (!$converter->{'set'}->{$key});
   }
   $converter->{'context'} = ['_Root_context'];
-  $converter->{'containers'} = [];
-  $converter->{'format_context'} = [{'cmdname' => '_top_format',
+  $converter->{'formatters'} = [];
+  $converter->{'format_context'} = [{
+                                     'cmdname' => '_top_format',
                                      'paragraph_count' => 0, 
                                      'indent_level' => 0,
                                       'max' => $converter->{'fillcolumn'}
@@ -287,41 +290,40 @@
   return $text;
 }
 
-sub new_container($$;$)
+sub new_formatter($$;$)
 {
   my $self = shift;
   my $type = shift;
   my $conf = shift;
 
-  
-  my $container_object;
-  my $paragraph_conf = { 
+  my $container;
+  my $container_conf = { 
          'max'           => $self->{'format_context'}->[-1]->{'max'},
          'frenchspacing' => $self->{'frenchspacing'},
          'indent_level' => $self->{'format_context'}->[-1]->{'indent_level'}, 
   };
   if ($conf) {
     foreach my $key (keys(%$conf)) {
-      $paragraph_conf->{$key} = $conf->{$key};
+      $container_conf->{$key} = $conf->{$key};
     }
   }
-  $paragraph_conf->{'indent_length'} = 
$indent_length*$paragraph_conf->{'indent_level'}
-    if (!defined($paragraph_conf->{'indent_length'}));
+  $container_conf->{'indent_length'} = 
$indent_length*$container_conf->{'indent_level'}
+    if (!defined($container_conf->{'indent_length'}));
   if ($type eq 'line') {
-    $container_object = Texinfo::Convert::Line->new($paragraph_conf);
+    $container = Texinfo::Convert::Line->new($container_conf);
   } elsif ($type eq 'paragraph') {
-    $container_object = Texinfo::Convert::Paragraph->new($paragraph_conf);
+    $container = Texinfo::Convert::Paragraph->new($container_conf);
   } elsif ($type eq 'unfilled') {
-    $container_object = Texinfo::Convert::UnFilled->new($paragraph_conf);
+    $container = Texinfo::Convert::UnFilled->new($container_conf);
   } else {
     die "Unknown container type $type\n";
   }
-  my $container = {'container' => $container_object, 'upper_case' => 0,
-                   'code' => 0};
+  my $formatter = {'container' => $container, 'upper_case' => 0,
+                   'code' => 0, 'w' => 0};
   if (defined($self->{'preformatted'})) {
-    $container->{'preformatted'} = $self->{'preformatted'};
+    $formatter->{'preformatted'} = $self->{'preformatted'};
   }
-  return $container;
+  return $formatter;
 }
 
 sub convert_line($$;$)
@@ -329,11 +331,11 @@
   my $self = shift;
   my $converted = shift;
   my $conf = shift;
-  my $container = $self->new_container('line', $conf);
-  push @{$self->{'containers'}}, $container;
+  my $container = $self->new_formatter('line', $conf);
+  push @{$self->{'formatters'}}, $container;
   my $result = $self->convert($converted);
   $result .= $container->{'container'}->end();
-  pop @{$self->{'containers'}};
+  pop @{$self->{'formatters'}};
   return $result;
 }
 
@@ -342,12 +344,12 @@
   my $self = shift;
   my $converted = shift;
   my $conf = shift;
-  my $container = $self->new_container('unfilled', $conf);
+  my $container = $self->new_formatter('unfilled', $conf);
   $container->{'code'} = 1;
-  push @{$self->{'containers'}}, $container;
+  push @{$self->{'formatters'}}, $container;
   my $result = $self->convert($converted);
   $result .= $container->{'container'}->end();
-  pop @{$self->{'containers'}};
+  pop @{$self->{'formatters'}};
   return $result;
 }
 
@@ -415,8 +417,8 @@
   my $root = shift;
 
   my $container_context;
-  if (@{$self->{'containers'}}) {
-    $container_context = $self->{'containers'}->[-1];
+  if (@{$self->{'formatters'}}) {
+    $container_context = $self->{'formatters'}->[-1];
   }
   if ($self->{'debug'}) {
     print STDERR "ROOT (@{$self->{'context'}}|@{$self->{'format_context'}})";
@@ -513,14 +515,24 @@
     } elsif ($style_map{$command}) {
       $container_context->{'code'}++ if ($code_style_commands{$command});
       $container_context->{'upper_case'}++ if ($upper_case_commands{$command});
+      if ($command eq 'w') {
+        $container_context->{'w'}++;
+        $container_context->{'container'}->set_space_protection(1,1)
+          if ($container_context->{'w'} == 1);
+      }
       $result .= 
$container_context->{'container'}->add_text($style_map{$command}->[0]);
       $result .= $self->convert($root->{'args'}->[0]) if ($root->{'args'});
       $result .= 
$container_context->{'container'}->add_text($style_map{$command}->[1]);
+      if ($command eq 'w') {
+        $container_context->{'w'}--;
+        $container_context->{'container'}->set_space_protection(0,0)
+          if ($container_context->{'w'} == 0);
+      }
       $container_context->{'code'}-- if ($code_style_commands{$command});
       $container_context->{'upper_case'}-- if ($upper_case_commands{$command});
     } elsif ($root->{'cmdname'} eq 'image') {
       # FIXME
-      return $self->convert($root->{'args'}->[0]);
+      #return $self->convert($root->{'args'}->[0]);
     } elsif ($root->{'cmdname'} eq 'email') {
       # nothing is output for email, instead the command is substituted.
 
@@ -545,6 +557,10 @@
       # TODO
     } elsif ($command eq 'anchor') {
       # TODO
+    } elsif ($ref_commands{$command}) {
+      # TODO
+    } elsif ($explained_commands{$command}) {
+      # TODO Beware that a . in abbr won't trigger double spaces.
     } elsif ($command eq 'math') {
       push @{$self->{'context'}}, 'math';
       $result .= $self->convert($root->{'args'}->[0]) if ($root->{'args'});
@@ -573,6 +589,7 @@
       # cartouche
       # flushleft and flushright -> keep track of result and add space
       #    at the end. do something specific here or at the end?
+      #    punctuation munging is done, but end of lines are kept.
 
       if ($preformatted_commands{$root->{'cmdname'}} or 
$menu_commands{$root->{'cmdname'}}) {
         push @{$self->{'context'}}, 'preformatted';
@@ -584,8 +601,8 @@
                    $self->{'format_context'}->[-1]->{'indent_level'} + 1,
                'max' => $self->{'format_context'}->[-1]->{'max'} };
         if ($self->{'context'}->[-1] eq 'preformatted') {
-          $preformatted = $self->new_container('unfilled');
-          push @{$self->{'containers'}}, $preformatted;
+          $preformatted = $self->new_formatter('unfilled');
+          push @{$self->{'formatters'}}, $preformatted;
         }
       }
       if ($root->{'cmdname'} eq 'quotation'
@@ -594,7 +611,8 @@
           my $quotation_arg = Texinfo::Convert::Texinfo::convert(
             {'contents' => 
$root->{'extra'}->{'block_command_line_contents'}->[0]});
           my $prepended = Texinfo::Parser::parse_texi_line (undef, 
'@b{'.${quotation_arg}.':} ');
-          $result = $self->convert_line($prepended);
+          $result = $self->convert_line ($prepended);
+
           #return gdt('@b{{quotation_arg}:} ', {'quotation_arg' => $text}, 
{'keep_texi' => 1});
           #$result = convert($root->{'args'}->[0]) ."\n";
         }
@@ -681,8 +699,8 @@
       # my $paragraphindent = get_conf('paragraphindent');
       # $paragraphindent = 0 if ($paragraphindent eq 'none');
       # if ($paragraphindent ne 'asis' and $paragraphindent and 
$line_char_counter == 0 and (defined($content->{'paragraph_in_element_nr'})) 
and ($info_state->{'indent_para'} or (!defined($info_state->{'indent_para'}) 
and ($content->{'paragraph_in_element_nr'} or (get_conf('firstparagraphindent') 
eq 'insert')))))
-      $paragraph = $self->new_container('paragraph');
-      push @{$self->{'containers'}}, $paragraph;
+      $paragraph = $self->new_formatter('paragraph');
+      push @{$self->{'formatters'}}, $paragraph;
       $self->{'format_context'}->[-1]->{'paragraph_count'}++;
     } elsif ($root->{'type'} eq 'def_line') {
     #print STDERR "$root->{'extra'}->{'def_command'}\n";
@@ -769,11 +787,11 @@
   }
   if ($paragraph) {
     $result .= $paragraph->{'container'}->end();
-    pop @{$self->{'containers'}};
+    pop @{$self->{'formatters'}};
   }
   if ($preformatted) {
     $result .= $preformatted->{'container'}->end();
-    pop @{$self->{'containers'}};
+    pop @{$self->{'formatters'}};
     pop @{$self->{'context'}};
   }
   pop @{$self->{'format_context'}} 

Index: t/03coverage_braces.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/03coverage_braces.t,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- t/03coverage_braces.t       9 Nov 2010 23:02:46 -0000       1.13
+++ t/03coverage_braces.t       21 Nov 2010 11:57:15 -0000      1.14
@@ -22,6 +22,16 @@
 }'],
 ['space_in_image','@image{ a ,bb, cc,dd ,e }. @image{ f }.'],
 ['empty_second_email_argument', '@email{ a@@b.c, }'],
+['empty_line_in_anchor',
+'@anchor{an
+
+anchor}
+'],
+['space_in_anchor',
+'@anchor{   anchor  name   }.
+']);
+
+my @test_invalid = (
 ['unmatched_brace','@samp{Closing} @samp{ @} without opening macro }.}'],
 ['brace_opened_no_command','address@hidden @anchor{truc}.
 @bye'],
@@ -38,14 +48,6 @@
 @bye
 '],
 ['code_not_closed','@code{in code'],
-['empty_line_in_anchor',
-'@anchor{an
-
-anchor}
-'],
-['space_in_anchor',
-'@anchor{   anchor  name   }.
-'],
 ['anchor_not_closed',
 '@anchor{my anchor
 
@@ -77,7 +79,11 @@
 
 our ($arg_test_case, $arg_generate, $arg_debug);
 
-run_all ('coverage_braces', address@hidden, $arg_test_case,
+foreach my $test (@test_cases) {
+  $test->[2]->{'test_formats'} = ['plaintext'];
+}
+
+run_all ('coverage_braces', address@hidden, @test_invalid], $arg_test_case,
    $arg_generate, $arg_debug);
 
 1;

Index: t/paragraph.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/paragraph.t,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- t/paragraph.t       21 Nov 2010 10:15:28 -0000      1.8
+++ t/paragraph.t       21 Nov 2010 11:57:15 -0000      1.9
@@ -9,7 +9,7 @@
 
 #use Test;
 use Test::More;
-BEGIN { plan tests => 93 };
+BEGIN { plan tests => 95 };
 use lib '../texi2html/lib/Unicode-EastAsianWidth/lib/';
 #push @INC, '../texi2html/lib/Unicode-EastAsianWidth/lib/';
 use Texinfo::Convert::Paragraph;
@@ -224,7 +224,7 @@
 
 $para = Texinfo::Convert::Paragraph->new({'max' => 2});
 $result = '';
-$para->set_space_protected(1);
+$para->set_space_protection(1,1);
 $result .= $para->add_text('aa.)    bb ');
 is ($result, 'aa.)    bb ', 'space protected 2 words');
 $result = $para->add_text(' eee ');
@@ -241,7 +241,7 @@
 $result .= $para->add_text("a");
 is ($result, 'gg.  ', 'protected space end line with already a space');
 $result = $para->add_text('  ');
-$para->set_space_protected(0);
+$para->set_space_protection(0,0);
 $result .= $para->add_text("c ");
 is ($result, "a  \nc", 'end protected space end of line');
 $para->end();
@@ -249,9 +249,9 @@
 $para = Texinfo::Convert::Paragraph->new();
 $result = '';
 $result .= $para->add_text('aa');
-$para->set_space_protected(1);
+$para->set_space_protection(1,1);
 $result .= $para->add_text('  f  f');
-$para->set_space_protected(0);
+$para->set_space_protection(0,0);
 $result .= $para->add_text("ggg\n");
 is ($result, 'aa  f  fggg', 'protected space within words');
 $para->end();
@@ -259,9 +259,9 @@
 $para = Texinfo::Convert::Paragraph->new();
 $result = '';
 $result = $para->add_text('aa');
-$para->set_space_protected(1);
+$para->set_space_protection(1,1);
 $result .= $para->add_text('  f  f ');
-$para->set_space_protected(0);
+$para->set_space_protection(0,0);
 $result .= $para->add_text("ggg\n");
 is ($result, 'aa  f  f ggg', 'protected space and space within words');
 $para->end();
@@ -269,9 +269,9 @@
 $para = Texinfo::Convert::Paragraph->new();
 $result = '';
 $result = $para->add_text('aa ');
-$result .= $para->set_space_protected(1);
+$result .= $para->set_space_protection(1,1);
 $result .= $para->add_text('  f  f ');
-$para->set_space_protected(0);
+$para->set_space_protection(0,0);
 $result .= $para->add_text("ggg\n");
 is ($result, 'aa   f  f ggg', 'text space protected space and space within 
words');
 $para->end();
@@ -279,9 +279,9 @@
 $para = Texinfo::Convert::Paragraph->new();
 $result = '';
 $result = $para->add_text('aa ');
-$result .= $para->set_space_protected(1);
+$result .= $para->set_space_protection(1,1);
 $result .= $para->add_text('  f  f ');
-$para->set_space_protected(0);
+$para->set_space_protection(0,0);
 $result .= $para->add_text(" ggg\n");
 is ($result, 'aa   f  f  ggg', 'text space protected space and space after');
 $para->end();
@@ -289,8 +289,8 @@
 $para = Texinfo::Convert::Paragraph->new();
 $result = '';
 $result = $para->add_text('aa ');
-$result .= $para->set_space_protected(1);
-$para->set_space_protected(0);
+$result .= $para->set_space_protection(1,1);
+$para->set_space_protection(0,0);
 $result .= $para->add_text(" ggg\n");
 is ($result, 'aa  ggg', 'empty protected 2 space');
 $para->end();
@@ -298,8 +298,8 @@
 $para = Texinfo::Convert::Paragraph->new();
 $result = '';
 $result = $para->add_text('aa ');
-$result .= $para->set_space_protected(1);
-$para->set_space_protected(0);
+$result .= $para->set_space_protection(1,1);
+$para->set_space_protection(0,0);
 $result .= $para->add_text("ggg\n");
 is ($result, 'aa ggg', 'empty protected 1 before space');
 $para->end();
@@ -307,8 +307,8 @@
 $para = Texinfo::Convert::Paragraph->new();
 $result = '';
 $result = $para->add_text('aa');
-$result .= $para->set_space_protected(1);
-$para->set_space_protected(0);
+$result .= $para->set_space_protection(1,1);
+$para->set_space_protection(0,0);
 $result .= $para->add_text(" ggg\n");
 is ($result, 'aa ggg', 'empty protected 1 after space');
 $para->end();
@@ -316,9 +316,9 @@
 $para = Texinfo::Convert::Paragraph->new();
 $result = '';
 $result = $para->add_text('aa ');
-$result .= $para->set_space_protected(1);
+$result .= $para->set_space_protection(1,1);
 $result .= $para->add_text(' ');
-$para->set_space_protected(0);
+$para->set_space_protection(0,0);
 $result .= $para->add_text(" ggg\n");
 is ($result, 'aa   ggg', 'space protected space');
 $para->end();
@@ -455,6 +455,18 @@
 $result .= $line->end();
 is ($result, "aa.))) after", 'line inhibit end sentence and ))');
 
+$line = Texinfo::Convert::Line->new();
+$result = '';
+$line->set_space_protection(1,1);
+$result .= $line->add_text(' aa.)');
+is ($result, " ", 'line space_protection leading space');
+$result .= $line->add_text(' ');
+$result .= $line->add_text('then');
+$result .= $line->add_text('fff     g');
+$line->set_space_protection(0,0);
+$result .= $line->end();
+is ($result, " aa.) thenfff     g", 'line space_protection and spaces');
+
 my $unfilled = Texinfo::Convert::UnFilled->new({'indent_length' => 5});
 $result = '';
 $result .= $unfilled->add_text("something\n");



reply via email to

[Prev in Thread] Current Thread [Next in Thread]