texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sun, 29 Sep 2024 14:24:36 -0400 (EDT)

branch: master
commit b6b0649ef2ca47d5cbe4221615a18c99b8490f50
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jul 6 15:26:42 2024 +0200

    * tp/Texinfo/Convert/Info.pm (format_ref),
    tp/Texinfo/Convert/Plaintext.pm (format_ref): double check that a
    reference is an internal reference before using the normalized
    reference as label.
    
    * tp/Makefile.tres, tp/t/info_tests.t
    (similar_external_and_internal_node): add a test with external and
    internal references with the same normalized node names.
---
 ChangeLog                                          |  11 +
 tp/Makefile.tres                                   |   1 +
 tp/Texinfo/Convert/Info.pm                         |   4 +
 tp/Texinfo/Convert/Plaintext.pm                    |   4 +
 tp/t/info_tests.t                                  |  11 +
 .../similar_external_and_internal_node.pl          | 385 +++++++++++++++++++++
 6 files changed, 416 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index a91e75c5f8..15833bf1d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-07-06  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/Info.pm (format_ref),
+       tp/Texinfo/Convert/Plaintext.pm (format_ref): double check that a
+       reference is an internal reference before using the normalized
+       reference as label.
+
+       * tp/Makefile.tres, tp/t/info_tests.t
+       (similar_external_and_internal_node): add a test with external and
+       internal references with the same normalized node names.
+
 2024-07-06  Patrice Dumas  <pertusus@free.fr>
 
        * tp/t/21multitable.t (ref_in_multitable), tp/t/converters_tests.t
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 7cb01401f9..c5f61e3217 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -1078,6 +1078,7 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/info_tests/quote_node_names_info/res_info \
   t/results/info_tests/recursive_down_menu.pl \
   t/results/info_tests/ref_tests.pl \
+  t/results/info_tests/similar_external_and_internal_node.pl \
   t/results/info_tests/space_at_menu_end.pl \
   t/results/info_tests/space_in_menu.pl \
   t/results/info_tests/space_in_setfilename.pl \
diff --git a/tp/Texinfo/Convert/Info.pm b/tp/Texinfo/Convert/Info.pm
index 89f40699e1..9c842a9a3d 100644
--- a/tp/Texinfo/Convert/Info.pm
+++ b/tp/Texinfo/Convert/Info.pm
@@ -536,7 +536,11 @@ sub format_ref($$$$)
 
   if ($node_arg and $node_arg->{'extra'}
       and !$node_arg->{'extra'}->{'manual_content'}
+      # excludes external nodes, as only internal refs get an extra normalized
       and defined($node_arg->{'extra'}->{'normalized'})
+      # exlude external nodes again, in case internal refs get normalized
+      and !defined($args[3])
+      and !defined($args[4])
       and $identifiers_target
       and $identifiers_target->{$node_arg->{'extra'}->{'normalized'}}) {
     $target_element
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index b89f492e84..9f536427a0 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -1988,7 +1988,11 @@ sub format_ref($$$$)
 
   if ($node_arg and $node_arg->{'extra'}
       and !$node_arg->{'extra'}->{'manual_content'}
+      # excludes external nodes, as only internal refs get an extra normalized
       and defined($node_arg->{'extra'}->{'normalized'})
+      # exlude external nodes again, in case internal refs get normalized
+      and !defined($args[3])
+      and !defined($args[4])
       and $identifiers_target
       and $identifiers_target->{$node_arg->{'extra'}->{'normalized'}}) {
     $target_element
diff --git a/tp/t/info_tests.t b/tp/t/info_tests.t
index 41caccae85..28080a11f0 100644
--- a/tp/t/info_tests.t
+++ b/tp/t/info_tests.t
@@ -251,6 +251,17 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
@xref{no:de,,, manual,Manual}
 ', undef,
 {'INFO_SPECIAL_CHARS_WARNING' => 0,}
 ],
+# the external node direction is there to be able to check the tree to
+# see that it gets a 'normalized' extra information, while the external
+# xref do not.
+['similar_external_and_internal_node',
+'@node aa, (toto)bb
+
+@xref{@emph{aa},,,ext}.
+@xref{@var{aa},,,,Book}.
+@xref{@emph{aa}}.
+@xref{@var{aa}}.
+'],
 ['xref_quote_long_item',
 '@table @asis
 
diff --git a/tp/t/results/info_tests/similar_external_and_internal_node.pl 
b/tp/t/results/info_tests/similar_external_and_internal_node.pl
new file mode 100644
index 0000000000..c011eb24fb
--- /dev/null
+++ b/tp/t/results/info_tests/similar_external_and_internal_node.pl
@@ -0,0 +1,385 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted %result_converted_errors 
+   %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'similar_external_and_internal_node'} = {
+  'contents' => [
+    {
+      'type' => 'before_node_section'
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'text' => 'aa'
+            }
+          ],
+          'type' => 'line_arg'
+        },
+        {
+          'contents' => [
+            {
+              'text' => '('
+            },
+            {
+              'text' => 'toto'
+            },
+            {
+              'text' => ')'
+            },
+            {
+              'text' => 'bb'
+            }
+          ],
+          'extra' => {
+            'manual_content' => {
+              'contents' => [
+                {}
+              ]
+            },
+            'node_content' => {
+              'contents' => [
+                {}
+              ]
+            },
+            'normalized' => 'bb'
+          },
+          'info' => {
+            'spaces_after_argument' => {
+              'text' => '
+'
+            },
+            'spaces_before_argument' => {
+              'text' => ' '
+            }
+          },
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'node',
+      'contents' => [
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        },
+        {
+          'contents' => [
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'args' => [
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'aa'
+                            }
+                          ],
+                          'type' => 'brace_container'
+                        }
+                      ],
+                      'cmdname' => 'emph',
+                      'source_info' => {
+                        'line_nr' => 3
+                      }
+                    }
+                  ],
+                  'extra' => {
+                    'node_content' => {
+                      'contents' => [
+                        {}
+                      ]
+                    }
+                  },
+                  'type' => 'brace_arg'
+                },
+                {
+                  'type' => 'brace_arg'
+                },
+                {
+                  'type' => 'brace_arg'
+                },
+                {
+                  'contents' => [
+                    {
+                      'text' => 'ext'
+                    }
+                  ],
+                  'type' => 'brace_arg'
+                }
+              ],
+              'cmdname' => 'xref',
+              'source_info' => {
+                'line_nr' => 3
+              }
+            },
+            {
+              'text' => '.
+'
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'args' => [
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'aa'
+                            }
+                          ],
+                          'type' => 'brace_container'
+                        }
+                      ],
+                      'cmdname' => 'var',
+                      'source_info' => {
+                        'line_nr' => 4
+                      }
+                    }
+                  ],
+                  'extra' => {
+                    'node_content' => {
+                      'contents' => [
+                        {}
+                      ]
+                    }
+                  },
+                  'type' => 'brace_arg'
+                },
+                {
+                  'type' => 'brace_arg'
+                },
+                {
+                  'type' => 'brace_arg'
+                },
+                {
+                  'type' => 'brace_arg'
+                },
+                {
+                  'contents' => [
+                    {
+                      'text' => 'Book'
+                    }
+                  ],
+                  'type' => 'brace_arg'
+                }
+              ],
+              'cmdname' => 'xref',
+              'source_info' => {
+                'line_nr' => 4
+              }
+            },
+            {
+              'text' => '.
+'
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'args' => [
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'aa'
+                            }
+                          ],
+                          'type' => 'brace_container'
+                        }
+                      ],
+                      'cmdname' => 'emph',
+                      'source_info' => {
+                        'line_nr' => 5
+                      }
+                    }
+                  ],
+                  'extra' => {
+                    'node_content' => {
+                      'contents' => [
+                        {}
+                      ]
+                    },
+                    'normalized' => 'aa'
+                  },
+                  'type' => 'brace_arg'
+                }
+              ],
+              'cmdname' => 'xref',
+              'source_info' => {
+                'line_nr' => 5
+              }
+            },
+            {
+              'text' => '.
+'
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'args' => [
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'aa'
+                            }
+                          ],
+                          'type' => 'brace_container'
+                        }
+                      ],
+                      'cmdname' => 'var',
+                      'source_info' => {
+                        'line_nr' => 6
+                      }
+                    }
+                  ],
+                  'extra' => {
+                    'node_content' => {
+                      'contents' => [
+                        {}
+                      ]
+                    },
+                    'normalized' => 'aa'
+                  },
+                  'type' => 'brace_arg'
+                }
+              ],
+              'cmdname' => 'xref',
+              'source_info' => {
+                'line_nr' => 6
+              }
+            },
+            {
+              'text' => '.
+'
+            }
+          ],
+          'type' => 'paragraph'
+        }
+      ],
+      'extra' => {
+        'is_target' => 1,
+        'normalized' => 'aa'
+      },
+      'info' => {
+        'spaces_before_argument' => {
+          'text' => ' '
+        }
+      },
+      'source_info' => {
+        'line_nr' => 1
+      }
+    }
+  ],
+  'type' => 'document_root'
+};
+$result_trees{'similar_external_and_internal_node'}{'contents'}[1]{'args'}[1]{'extra'}{'manual_content'}{'contents'}[0]
 = 
$result_trees{'similar_external_and_internal_node'}{'contents'}[1]{'args'}[1]{'contents'}[1];
+$result_trees{'similar_external_and_internal_node'}{'contents'}[1]{'args'}[1]{'extra'}{'node_content'}{'contents'}[0]
 = 
$result_trees{'similar_external_and_internal_node'}{'contents'}[1]{'args'}[1]{'contents'}[3];
+$result_trees{'similar_external_and_internal_node'}{'contents'}[1]{'contents'}[1]{'contents'}[0]{'args'}[0]{'extra'}{'node_content'}{'contents'}[0]
 = 
$result_trees{'similar_external_and_internal_node'}{'contents'}[1]{'contents'}[1]{'contents'}[0]{'args'}[0]{'contents'}[0];
+$result_trees{'similar_external_and_internal_node'}{'contents'}[1]{'contents'}[1]{'contents'}[2]{'args'}[0]{'extra'}{'node_content'}{'contents'}[0]
 = 
$result_trees{'similar_external_and_internal_node'}{'contents'}[1]{'contents'}[1]{'contents'}[2]{'args'}[0]{'contents'}[0];
+$result_trees{'similar_external_and_internal_node'}{'contents'}[1]{'contents'}[1]{'contents'}[4]{'args'}[0]{'extra'}{'node_content'}{'contents'}[0]
 = 
$result_trees{'similar_external_and_internal_node'}{'contents'}[1]{'contents'}[1]{'contents'}[4]{'args'}[0]{'contents'}[0];
+$result_trees{'similar_external_and_internal_node'}{'contents'}[1]{'contents'}[1]{'contents'}[6]{'args'}[0]{'extra'}{'node_content'}{'contents'}[0]
 = 
$result_trees{'similar_external_and_internal_node'}{'contents'}[1]{'contents'}[1]{'contents'}[6]{'args'}[0]{'contents'}[0];
+
+$result_texis{'similar_external_and_internal_node'} = '@node aa, (toto)bb
+
+@xref{@emph{aa},,,ext}.
+@xref{@var{aa},,,,Book}.
+@xref{@emph{aa}}.
+@xref{@var{aa}}.
+';
+
+
+$result_texts{'similar_external_and_internal_node'} = '
+aa.
+aa.
+aa.
+aa.
+';
+
+$result_nodes{'similar_external_and_internal_node'} = [
+  {
+    'cmdname' => 'node',
+    'extra' => {
+      'node_directions' => {
+        'next' => {
+          'extra' => {
+            'manual_content' => {},
+            'normalized' => 'bb'
+          },
+          'type' => 'line_arg'
+        }
+      },
+      'normalized' => 'aa'
+    }
+  }
+];
+
+$result_menus{'similar_external_and_internal_node'} = [
+  {
+    'extra' => {
+      'normalized' => 'aa'
+    }
+  }
+];
+
+$result_errors{'similar_external_and_internal_node'} = [
+  {
+    'error_line' => 'warning: @xref to `@emph{aa}\', different from node name 
`aa\'
+',
+    'line_nr' => 5,
+    'text' => '@xref to `@emph{aa}\', different from node name `aa\'',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @xref to `@var{aa}\', different from node name 
`aa\'
+',
+    'line_nr' => 6,
+    'text' => '@xref to `@var{aa}\', different from node name `aa\'',
+    'type' => 'warning'
+  }
+];
+
+
+$result_floats{'similar_external_and_internal_node'} = {};
+
+
+
+$result_converted{'info'}->{'similar_external_and_internal_node'} = 'This is , 
produced from .
+
+
+File: ,  Node: aa,  Next: (toto)bb
+
+*Note (ext)_aa_::.  *Note ()AA::.  *Note aa::.  *Note aa::.
+
+
+Tag Table:
+Node: aa27
+
+End Tag Table
+
+
+Local Variables:
+coding: utf-8
+End:
+';
+
+$result_converted_errors{'info'}->{'similar_external_and_internal_node'} = [
+  {
+    'error_line' => 'warning: document without Top node
+',
+    'text' => 'document without Top node',
+    'type' => 'warning'
+  }
+];
+
+
+1;



reply via email to

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