texinfo-commits
[Top][All Lists]
Advanced

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

[6520] implement nodename quoting for makeinfo


From: Gavin D. Smith
Subject: [6520] implement nodename quoting for makeinfo
Date: Thu, 13 Aug 2015 18:24:07 +0000

Revision: 6520
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6520
Author:   gavin
Date:     2015-08-13 18:24:06 +0000 (Thu, 13 Aug 2015)
Log Message:
-----------
implement nodename quoting for makeinfo

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/tp/Texinfo/Common.pm
    trunk/tp/Texinfo/Convert/Info.pm
    trunk/tp/Texinfo/Convert/Plaintext.pm
    trunk/tp/t/results/coverage_braces/uref_in_ref.pl
    trunk/tp/t/results/info_tests/invalid_node_name_warning.pl
    trunk/tp/t/results/info_tests/ref_tests.pl
    trunk/tp/t/results/info_tests/xref_test.pl

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2015-08-13 09:55:02 UTC (rev 6519)
+++ trunk/ChangeLog     2015-08-13 18:24:06 UTC (rev 6520)
@@ -1,5 +1,19 @@
 2015-08-13  Gavin Smith  <address@hidden>
 
+       * tp/Texinfo/Common.pm (@variable_string_settables): Add 
+       'INFO_SPECIAL_CHARS_QUOTE'.
+       * tp/Texinfo/Convert/Info.pm (_node) <INFO_SPECIAL_CHARS_QUOTE>: 
+       Add quoting characters around node name if required.
+       * tp/Texinfo/Convert/Plaintext.pm (_convert) <xrefs and menus>
+       <INFO_SPECIAL_CHARS_QUOTE>: Add quoting characters around 
+       segments of cross-references and menu entries if they contain 
+       problematic characters.
+       <xrefs> <INFO_SPECIAL_CHARS_WARNING>: Warn if a node name 
+       contains a full stop even if it is not followed by whitespace, 
+       as this still breaks readers.
+
+2015-08-13  Gavin Smith  <address@hidden>
+
        * tp/Texinfo/Convert/HTML.pm (_convert_enumerate_command): Use
        <ol start="NUMBER"> for numeric argument other than 1.
 

Modified: trunk/tp/Texinfo/Common.pm
===================================================================
--- trunk/tp/Texinfo/Common.pm  2015-08-13 09:55:02 UTC (rev 6519)
+++ trunk/tp/Texinfo/Common.pm  2015-08-13 18:24:06 UTC (rev 6520)
@@ -265,7 +265,7 @@
   'MACRO_BODY_IGNORES_LEADING_SPACE', 'CHECK_HTMLXREF',
   'TEXINFO_DTD_VERSION', 'TEXINFO_COLUMN_FOR_DESCRIPTION',
   'TEXINFO_OUTPUT_FORMAT', 'INFO_SPECIAL_CHARS_WARNING',
-  'INDEX_SPECIAL_CHARS_WARNING',
+  'INDEX_SPECIAL_CHARS_WARNING', 'INFO_SPECIAL_CHARS_QUOTE'
 );
 # Not strings. 
 # FIXME To be documented somewhere, but where?

Modified: trunk/tp/Texinfo/Convert/Info.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Info.pm    2015-08-13 09:55:02 UTC (rev 6519)
+++ trunk/tp/Texinfo/Convert/Info.pm    2015-08-13 18:24:06 UTC (rev 6520)
@@ -414,13 +414,22 @@
   $result .= $node_begin;
   $self->_add_text_count($node_begin);
   my ($node_text, $byte_count) = $self->_node_line($node);
-  if ($node_text =~ /,/ and $self->get_conf('INFO_SPECIAL_CHARS_WARNING')) {
-    $self->line_warn(sprintf($self->__(
-               "address@hidden name should not contain `,': %s"), $node_text),
-                             $node->{'line_nr'});
+  my $pre_quote = '';
+  my $post_quote = '';
+  if ($node_text =~ /,/) {
+    if ($self->get_conf('INFO_SPECIAL_CHARS_WARNING')) {
+      $self->line_warn(sprintf($self->__(
+                 "address@hidden name should not contain `,': %s"), 
$node_text),
+                               $node->{'line_nr'});
+    }
+    if ($self->get_conf('INFO_SPECIAL_CHARS_QUOTE')) {
+      $pre_quote = "\x{7f}";
+      $post_quote = $pre_quote;
+      $self->{'count_context'}->[-1]->{'bytes'} += 2;
+    }
   }
   $self->{'count_context'}->[-1]->{'bytes'} += $byte_count;
-  $result .= $node_text;
+  $result .= $pre_quote . $node_text . $post_quote;
   foreach my $direction(@directions) {
     if ($node->{'node_'.lc($direction)}) {
       my $node_direction = $node->{'node_'.lc($direction)};

Modified: trunk/tp/Texinfo/Convert/Plaintext.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Plaintext.pm       2015-08-13 09:55:02 UTC (rev 
6519)
+++ trunk/tp/Texinfo/Convert/Plaintext.pm       2015-08-13 18:24:06 UTC (rev 
6520)
@@ -2151,14 +2151,26 @@
           # needed, as last word is added only when : is added below
           my $name_text_checked = $name_text
              .$self->{'formatters'}->[-1]->{'container'}->get_pending();
-          if ($name_text_checked =~ /:/m 
-              and $self->get_conf('INFO_SPECIAL_CHARS_WARNING')) {
-            $self->line_warn(sprintf($self->__(
-               "address@hidden cross-reference name should not contain `:'"), 
$command),
-                             $root->{'line_nr'});
+          my $quoting_required = 0;
+          if ($name_text_checked =~ /:/m) { 
+              if ($self->get_conf('INFO_SPECIAL_CHARS_WARNING')) {
+                $self->line_warn(sprintf($self->__(
+                   "address@hidden cross-reference name should not contain 
`:'"),
+                                               $command), $root->{'line_nr'});
+              }
+              if ($self->get_conf('INFO_SPECIAL_CHARS_QUOTE')) {
+                $quoting_required = 1;
+              }
           }
+          my $pre_quote = $quoting_required ? "\x{7f}" : '';
+          my $post_quote = $pre_quote;
+          $name_text .= $self->_convert({'contents' => [
+                {'text' => "$post_quote: "}]});
+          $name_text =~ s/^(\s*)/$1$pre_quote/ if $pre_quote;
           $result .= $name_text;
-          $result .= $self->_convert({'contents' => [{'text' => ': '}]});
+          _count_added($self,$self->{'formatters'}[-1]{'container'},
+                       $pre_quote)
+            if $pre_quote;
 
           if ($file) {
             $result .= $self->_convert({'contents' => $file});
@@ -2171,14 +2183,26 @@
 
           my $node_text_checked = $node_text 
              .$self->{'formatters'}->[-1]->{'container'}->get_pending();
-          if ($node_text_checked =~ /([,\t]|\.\s)/m 
-              and $self->get_conf('INFO_SPECIAL_CHARS_WARNING')) {
-            $self->line_warn(sprintf($self->__(
-               "address@hidden node name should not contain `%s'"), $command, 
$1),
-                             $root->{'line_nr'});
+          $quoting_required = 0;
+          if ($node_text_checked =~ /([,\t\.])/m ) {
+              if ($self->get_conf('INFO_SPECIAL_CHARS_WARNING')) {
+                $self->line_warn(sprintf($self->__(
+                   "address@hidden node name should not contain `%s'"), 
$command, $1),
+                                 $root->{'line_nr'});
+              }
+              if ($self->get_conf('INFO_SPECIAL_CHARS_QUOTE')) {
+                $quoting_required = 1;
+              }
           }
+          $pre_quote = $quoting_required ? "\x{7f}" : '';
+          $post_quote = $pre_quote;
+          $node_text =~ s/^(\s*)/$1$pre_quote/ if $pre_quote;
+          _count_added($self,$self->{'formatters'}[-1]{'container'},
+                       $pre_quote);
           $result .= $node_text;
-        } else {
+          _count_added($self,$self->{'formatters'}[-1]{'container'},
+            $self->{'formatters'}->[-1]->{'container'}->add_next($post_quote));
+        } else { # Label same as node specification
           if ($file) {
             $result .= $self->_convert({'contents' => $file});
           }
@@ -2189,14 +2213,37 @@
 
           my $node_text_checked = $node_text 
              .$self->{'formatters'}->[-1]->{'container'}->get_pending();
-          if ($node_text_checked =~ /:/m
-              and $self->get_conf('INFO_SPECIAL_CHARS_WARNING')) {
-            $self->line_warn(sprintf($self->__(
-               "address@hidden node name should not contain `:'"), $command),
-                             $root->{'line_nr'});
+          my $quoting_required = 0;
+          if ($node_text_checked =~ /:/m) {
+            if ($self->get_conf('INFO_SPECIAL_CHARS_WARNING')) {
+              $self->line_warn(sprintf($self->__(
+                 "address@hidden node name should not contain `:'"), $command),
+                               $root->{'line_nr'});
+            }
+            if ($self->get_conf('INFO_SPECIAL_CHARS_QUOTE')) {
+              $quoting_required = 1;
+            }
           }
+          my $pre_quote = $quoting_required ? "\x{7f}" : '';
+          my $post_quote = $pre_quote;
+          $node_text .= $self->_convert({'contents' => [
+                {'text' => "${post_quote}::"}]});
+          _count_added($self,$self->{'formatters'}[-1]{'container'},
+                       $pre_quote)
+            if $pre_quote;
+          if ($pre_quote) {
+            # This is needed to get a pending word.  We could use
+            # add_pending_word, but that would not include following 
+            # punctuation in the word.
+            my $next = $self->{'current_contents'}->[-1]->[0];
+            if ($next) {
+              $node_text .= $self->_convert($next);
+              shift @{$self->{'current_contents'}->[-1]};
+            }
+
+            $node_text =~ s/^(\s*)/$1$pre_quote/;
+          }
           $result .= $node_text;
-          $result .= $self->_convert({'contents' => [{'text' => '::'}]});
         }
         # we could use $formatter, but in case it was changed in _convert 
         # we play it safe.
@@ -2206,7 +2253,8 @@
         # If command is @xref, the punctuation must always follow the
         # command, for other commands it may be in the argument, hence the
         # use of $pending.
-        if ($command eq 'xref' or ($pending !~ /[\.,]$/ and $pending !~ 
/::$/)) {
+        if ($name and ($command eq 'xref'
+            or ($pending !~ /[\.,]$/ and $pending !~ /::$/))) {
           my $next = $self->{'current_contents'}->[-1]->[0];
           if (!($next and $next->{'text'} and $next->{'text'} =~ /^[\.,]/)) {
             if ($command eq 'xref') {
@@ -3047,38 +3095,53 @@
       #}
       my $entry_name_seen = 0;
       foreach my $arg (@{$root->{'args'}}) {
+        my ($pre_quote, $post_quote);
         if ($arg->{'type'} eq 'menu_entry_node') {
           $self->{'formatters'}->[-1]->{'suppress_styles'} = 1;
           my $node_text = $self->_convert({'type' => '_code',
                                       'contents' => $arg->{'contents'}});
 
           delete $self->{'formatters'}->[-1]->{'suppress_styles'};
+          $pre_quote = $post_quote = '';
           if ($entry_name_seen) {
-            if ($node_text =~ /([,\t]|\.\s)/
-                and $self->get_conf('INFO_SPECIAL_CHARS_WARNING')) {
-              $self->line_warn(sprintf($self->__(
-                 "menu entry node name should not contain `%s'"), $1),
-                             $root->{'line_nr'});
+            if ($node_text =~ /([,\t]|\.\s)/) {
+              if ($self->get_conf('INFO_SPECIAL_CHARS_WARNING')) {
+                $self->line_warn(sprintf($self->__(
+                   "menu entry node name should not contain `%s'"), $1),
+                               $root->{'line_nr'});
+              }
             }
+            if ($self->get_conf('INFO_SPECIAL_CHARS_QUOTE')) {
+              $pre_quote = $post_quote = "\x{7f}";
+            }
           } else {
-            if ($node_text =~ /:/
-                and $self->get_conf('INFO_SPECIAL_CHARS_WARNING')) {
-              $self->line_warn($self->__(
-               "menu entry node name should not contain `:'"),
-                             $root->{'line_nr'});
+            if ($node_text =~ /:/) {
+              if ($self->get_conf('INFO_SPECIAL_CHARS_WARNING')) {
+                $self->line_warn($self->__(
+                 "menu entry node name should not contain `:'"),
+                               $root->{'line_nr'});
+              }
+              if ($self->get_conf('INFO_SPECIAL_CHARS_QUOTE')) {
+                $pre_quote = $post_quote = "\x{7f}";
+              }
             }
           }
-          $result .= $node_text;
+          $result .= $pre_quote . $node_text . $post_quote;
         } elsif ($arg->{'type'} eq 'menu_entry_name') {
           my $entry_name = $self->_convert($arg);
           $entry_name_seen = 1;
-          if ($entry_name =~ /:/
-              and $self->get_conf('INFO_SPECIAL_CHARS_WARNING')) {
-            $self->line_warn($self->__(
-               "menu entry name should not contain `:'"),
-                             $root->{'line_nr'});
+          $pre_quote = $post_quote = '';
+          if ($entry_name =~ /:/) {
+            if ($self->get_conf('INFO_SPECIAL_CHARS_WARNING')) {
+              $self->line_warn($self->__(
+                 "menu entry name should not contain `:'"),
+                               $root->{'line_nr'});
+            }
+            if ($self->get_conf('INFO_SPECIAL_CHARS_QUOTE')) {
+              $pre_quote = $post_quote = "\x{7f}";
+            }
           }
-          $result .= $entry_name;
+          $result .= $pre_quote . $entry_name . $post_quote;
         } else {
           $result .= $self->_convert($arg);
         }

Modified: trunk/tp/t/results/coverage_braces/uref_in_ref.pl
===================================================================
--- trunk/tp/t/results/coverage_braces/uref_in_ref.pl   2015-08-13 09:55:02 UTC 
(rev 6519)
+++ trunk/tp/t/results/coverage_braces/uref_in_ref.pl   2015-08-13 18:24:06 UTC 
(rev 6520)
@@ -391,6 +391,15 @@
     'macro' => '',
     'text' => '@ref cross-reference name should not contain `:\'',
     'type' => 'warning'
+  },
+  {
+    'error_line' => ':1: warning: @ref node name should not contain `.\'
+',
+    'file_name' => '',
+    'line_nr' => 1,
+    'macro' => '',
+    'text' => '@ref node name should not contain `.\'',
+    'type' => 'warning'
   }
 ];
 

Modified: trunk/tp/t/results/info_tests/invalid_node_name_warning.pl
===================================================================
--- trunk/tp/t/results/info_tests/invalid_node_name_warning.pl  2015-08-13 
09:55:02 UTC (rev 6519)
+++ trunk/tp/t/results/info_tests/invalid_node_name_warning.pl  2015-08-13 
18:24:06 UTC (rev 6520)
@@ -1257,12 +1257,12 @@
     'type' => 'warning'
   },
   {
-    'error_line' => ':16: warning: @ref node name should not contain `. \'
+    'error_line' => ':16: warning: @ref node name should not contain `.\'
 ',
     'file_name' => '',
     'line_nr' => 16,
     'macro' => '',
-    'text' => '@ref node name should not contain `. \'',
+    'text' => '@ref node name should not contain `.\'',
     'type' => 'warning'
   },
   {

Modified: trunk/tp/t/results/info_tests/ref_tests.pl
===================================================================
--- trunk/tp/t/results/info_tests/ref_tests.pl  2015-08-13 09:55:02 UTC (rev 
6519)
+++ trunk/tp/t/results/info_tests/ref_tests.pl  2015-08-13 18:24:06 UTC (rev 
6520)
@@ -742,4 +742,17 @@
 End Tag Table
 ';
 
+$result_converted_errors{'info'}->{'ref_tests'} = [
+  {
+    'error_line' => ':12: warning: @ref node name should not contain `.\'
+',
+    'file_name' => '',
+    'line_nr' => 12,
+    'macro' => '',
+    'text' => '@ref node name should not contain `.\'',
+    'type' => 'warning'
+  }
+];
+
+
 1;

Modified: trunk/tp/t/results/info_tests/xref_test.pl
===================================================================
--- trunk/tp/t/results/info_tests/xref_test.pl  2015-08-13 09:55:02 UTC (rev 
6519)
+++ trunk/tp/t/results/info_tests/xref_test.pl  2015-08-13 18:24:06 UTC (rev 
6520)
@@ -486,9 +486,9 @@
 
 File: ,  Node: Top,  Up: (dir)
 
-*Note (m)in xref::.  *Note (m)bad xref::.  after xref.  \'*Note (m)bad
-nested xref::.\'.  *Note name: (m)in ref ending with a dot..  !  after
-xref and dot inside.  *Note (m)in ref followed by symbol::.# g.
+*Note (m)in xref::.  *Note (m)bad xref:: after xref.  \'*Note (m)bad
+nested xref::\'.  *Note name: (m)in ref ending with a dot..  !  after
+xref and dot inside.  *Note (m)in ref followed by symbol::# g.
 
 
 Tag Table:
@@ -499,24 +499,15 @@
 
 $result_converted_errors{'info'}->{'xref_test'} = [
   {
-    'error_line' => ':4: warning: `.\' or `,\' must follow @xref, not a
+    'error_line' => ':6: warning: @xref node name should not contain `.\'
 ',
     'file_name' => '',
-    'line_nr' => 4,
+    'line_nr' => 6,
     'macro' => '',
-    'text' => '`.\' or `,\' must follow @xref, not a',
+    'text' => '@xref node name should not contain `.\'',
     'type' => 'warning'
   },
   {
-    'error_line' => ':5: warning: `.\' or `,\' must follow @xref
-',
-    'file_name' => '',
-    'line_nr' => 5,
-    'macro' => '',
-    'text' => '`.\' or `,\' must follow @xref',
-    'type' => 'warning'
-  },
-  {
     'error_line' => ':6: warning: `.\' or `,\' must follow @xref, not !
 ',
     'file_name' => '',
@@ -524,15 +515,6 @@
     'macro' => '',
     'text' => '`.\' or `,\' must follow @xref, not !',
     'type' => 'warning'
-  },
-  {
-    'error_line' => ':7: warning: `.\' or `,\' must follow @xref, not #
-',
-    'file_name' => '',
-    'line_nr' => 7,
-    'macro' => '',
-    'text' => '`.\' or `,\' must follow @xref, not #',
-    'type' => 'warning'
   }
 ];
 




reply via email to

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