texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: Info output for reference commands


From: Gavin D. Smith
Subject: branch master updated: Info output for reference commands
Date: Mon, 15 Aug 2022 18:25:53 -0400

This is an automated email from the git hooks/post-receive script.

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 8ccbe3937a Info output for reference commands
8ccbe3937a is described below

commit 8ccbe3937afd7655e3a7ee28e3d137b15ce3796b
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Mon Aug 15 23:25:23 2022 +0100

    Info output for reference commands
    
    * tp/Texinfo/Convert/Plaintext.pm (_convert) <ref commands>:
    Combine code handling an xref with a separate label with code
    where the node name is the label.  Both blocks of code were
    very similar apart from different requirements for DEL-quoting.
    Check for following punctuation slightly differently
    and integrate better with DEL-quoting mechanism.
---
 ChangeLog                                          |  11 ++
 tp/Texinfo/Convert/Plaintext.pm                    | 164 ++++++++++-----------
 tp/t/results/info_tests/ref_tests.pl               |   2 +-
 .../res_plaintext/quote_node_names.txt             |   2 +-
 4 files changed, 92 insertions(+), 87 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a22d029606..efcc3a830c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2022-08-15  Gavin Smith  <gavinsmith0123@gmail.com>
+
+       Info output for reference commands
+
+       * tp/Texinfo/Convert/Plaintext.pm (_convert) <ref commands>:
+       Combine code handling an xref with a separate label with code
+       where the node name is the label.  Both blocks of code were
+       very similar apart from different requirements for DEL-quoting.
+       Check for following punctuation slightly differently
+       and integrate better with DEL-quoting mechanism.
+
 2022-08-15  Patrice Dumas  <pertusus@free.fr>
 
        Give recommendations on markup on @def* lines
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 7f8bd15378..3d894ea533 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -2129,100 +2129,94 @@ sub _convert($$)
           _count_added($self,$self->{'formatters'}[-1]{'container'},
                        $pre_quote)
             if $pre_quote;
+        }
 
-          if ($file) {
-            $result .= _convert($self, {'contents' => $file});
-          }
-          # node name
-          $self->{'formatters'}->[-1]->{'suppress_styles'} = 1;
+        if ($file) {
+          $result .= _convert($self, {'contents' => $file});
+        }
 
-          my $maybe_file
-            = get_pending($self->{'formatters'}->[-1]->{'container'});
-          my $node_text = _convert($self, {'type' => '_code',
-                                           'contents' => $node_content});
-          delete $self->{'formatters'}->[-1]->{'suppress_styles'};
+        # node name
+        $self->{'formatters'}->[-1]->{'suppress_styles'} = 1;
+        my $maybe_file
+          = get_pending($self->{'formatters'}->[-1]->{'container'});
+        my $node_text = _convert($self, {'type' => '_code',
+                                         'contents' => $node_content});
+        delete $self->{'formatters'}->[-1]->{'suppress_styles'};
+
+        my $node_text_checked = $node_text
+           .get_pending($self->{'formatters'}->[-1]->{'container'});
+        $maybe_file =~ s/^\s*//;
+        $maybe_file = quotemeta $maybe_file;
+        $node_text_checked =~ s/^\s*$maybe_file//;
+        my $quoting_required = 0;
+
+        my $check_chars;
+        if ($name) {
+          $check_chars = quotemeta ",\t.";
+        } else {
+          $check_chars = quotemeta ":";
+        }
 
-          my $node_text_checked = $node_text 
-             .get_pending($self->{'formatters'}->[-1]->{'container'});
-          $maybe_file =~ s/^\s*//;
-          $maybe_file = quotemeta $maybe_file;
-          $node_text_checked =~ s/^\s*$maybe_file//;
-          $quoting_required = 0;
-          if ($node_text_checked =~ /([,\t\.])/m ) {
-            if ($self->{'info_special_chars_warning'}) {
-              $self->line_warn($self, sprintf(__(
-                 "\@%s node name should not contain `%s'"), $command, $1),
-                               $element->{'source_info'});
-            }
-            if ($self->{'info_special_chars_quote'}) {
-              $quoting_required = 1;
-            }
+        if ($node_text_checked =~ /([$check_chars])/m){
+          if ($self->{'info_special_chars_warning'}) {
+            $self->line_warn($self, sprintf(__(
+               "\@%s node name should not contain `%s'"), $command, $1),
+                             $element->{'source_info'});
           }
-          $pre_quote = $quoting_required ? "\x{7f}" : '';
-          $post_quote = $pre_quote;
-          if ($pre_quote) {
-            $node_text =~ s/^(\s*)/$1$pre_quote/;
-            _count_added($self,$self->{'formatters'}[-1]{'container'},
-                         $pre_quote);
+          if ($self->{'info_special_chars_quote'}) {
+            $quoting_required = 1;
           }
-          $result .= $node_text;
-          _count_added($self, $self->{'formatters'}[-1]{'container'},
-            add_next($self->{'formatters'}->[-1]->{'container'}, $post_quote))
-                 if $post_quote;
-        } else { # Label same as node specification
-          if ($file) {
-            $result .= _convert($self, {'contents' => $file});
-          }
-          $self->{'formatters'}->[-1]->{'suppress_styles'} = 1;
-          my $node_text = _convert($self, {'type' => '_code',
-                                           'contents' => $node_content});
-          delete $self->{'formatters'}->[-1]->{'suppress_styles'};
+        }
+        my $pre_quote = $quoting_required ? "\x{7f}" : '';
+        my $post_quote = $pre_quote;
+
+        $node_text .= _count_added($self,
+          $self->{'formatters'}[-1]{'container'},
+          add_next($self->{'formatters'}->[-1]->{'container'}, $post_quote))
+               if $post_quote;
+
+        if (!$name) {
+          $node_text .= _count_added($self,
+            $self->{'formatters'}[-1]{'container'},
+            add_next($self->{'formatters'}->[-1]->{'container'}, '::'));
+        }
 
-          my $node_text_checked = $node_text 
-             .get_pending($self->{'formatters'}->[-1]->{'container'});
-          my $quoting_required = 0;
-          if ($node_text_checked =~ /:/m) {
-            if ($self->{'info_special_chars_warning'}) {
-              $self->line_warn($self, sprintf(__(
-                 "\@%s node name should not contain `:'"), $command),
-                               $element->{'source_info'});
-            }
-            if ($self->{'info_special_chars_quote'}) {
-              $quoting_required = 1;
-            }
-          }
-          my $pre_quote = $quoting_required ? "\x{7f}" : '';
-          my $post_quote = $pre_quote;
-          $node_text .= _convert($self, {'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 .= _convert($self, $next);
-              shift @{$self->{'current_contents'}->[-1]};
-            }
+        my $following = '';
+        my $maybe_leading
+          = get_pending($self->{'formatters'}->[-1]->{'container'});
 
-            $node_text =~ s/^(\s*)/$1$pre_quote/;
+        if ($pre_quote) {
+          # Try to output enough that the node name is output so we can
+          # insert $pre_quote before it.
+          # We could use add_pending_word, but this could lead to
+          # the line being broken too late.
+          my $next = $self->{'current_contents'}->[-1]->[0];
+          if ($next) {
+            $following = _convert($self, $next);
+            $node_text .= $following;
+            shift @{$self->{'current_contents'}->[-1]};
           }
-          $result .= $node_text;
-        }
-        # we could use $formatter, but in case it was changed in _convert 
-        # we play it safe.
-        my $pending = $result 
-             .get_pending($self->{'formatters'}->[-1]->{'container'});
 
-        # 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.
-        # FIXME: is @xref really special here?
-        if ($name and ($command eq 'xref'
-            or ($pending !~ /[\.,]$/ and $pending !~ /::$/))) {
+          $node_text =~ s/^(\s*)/$1$pre_quote/;
+          _count_added($self,$self->{'formatters'}[-1]{'container'},
+                       $pre_quote);
+        }
+        $result .= $node_text;
+
+        # Check if punctuation follows the ref command.  If we converted
+        # past the ref command, check if the excess starts with one of the
+        # characters.  Do this by stripping off the leading text that
+        # contains the output from the ref command.
+        #
+        # FIXME: is @xref really special here?  Original comment:
+        # "If command is @xref, the punctuation must always follow the
+        # command, for other commands it may be in the argument..."
+
+        $following .= get_pending($self->{'formatters'}->[-1]->{'container'});
+        $maybe_leading = quotemeta $maybe_leading;
+        $following =~ s/^$maybe_leading//;
+
+        if ($name and $following !~ /^[\.,]/) {
           my $next = $self->{'current_contents'}->[-1]->[0];
           if (!($next and $next->{'text'} and $next->{'text'} =~ /^[\.,]/)) {
             if ($command eq 'xref') {
diff --git a/tp/t/results/info_tests/ref_tests.pl 
b/tp/t/results/info_tests/ref_tests.pl
index 3406d57736..5e9d6aa010 100644
--- a/tp/t/results/info_tests/ref_tests.pl
+++ b/tp/t/results/info_tests/ref_tests.pl
@@ -681,7 +681,7 @@ comma:: after ref.  ‘*note (m)in ref followed by end 
command::’.
 
    *note name: (m)in ref followed by comma, *note name: (m)in ref not
 followed by comma. after ref.  ‘*note name: (m)in ref followed by end
-command.’.  *note name: (m)in ref ending with a dot. after ref.
+command.’.  *note name: (m)in ref ending with a dot.. after ref.
 
 
 
diff --git 
a/tp/t/results/plaintext_tests/quote_node_names/res_plaintext/quote_node_names.txt
 
b/tp/t/results/plaintext_tests/quote_node_names/res_plaintext/quote_node_names.txt
index bd69207907..62445d3d4f 100644
--- 
a/tp/t/results/plaintext_tests/quote_node_names/res_plaintext/quote_node_names.txt
+++ 
b/tp/t/results/plaintext_tests/quote_node_names/res_plaintext/quote_node_names.txt
@@ -4,7 +4,7 @@ node.
    *Note the::caption and a word: blah:blah. *Note the::caption:
 blah:blah.
 
-   *Note the::caption and a word: blumpty.fump. *Note the::caption:
+   *Note the::caption and a word: blumpty.fump .*Note the::caption:
 blumpty.fump.mrmrmrmmrmrmr
 
    *Note blah:blah::



reply via email to

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