texinfo-commits
[Top][All Lists]
Advanced

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

[7195] move explanation_contents out of Parser.pm


From: gavinsmith0123
Subject: [7195] move explanation_contents out of Parser.pm
Date: Sun, 29 May 2016 13:30:10 +0000 (UTC)

Revision: 7195
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7195
Author:   gavin
Date:     2016-05-29 13:30:10 +0000 (Sun, 29 May 2016)
Log Message:
-----------
move explanation_contents out of Parser.pm

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/tp/Texinfo/Convert/HTML.pm
    trunk/tp/Texinfo/Parser.pm
    trunk/tp/t/results/converters_tests/at_commands_in_raw.pl
    trunk/tp/t/results/converters_tests/at_commands_in_refs.pl
    trunk/tp/t/results/converters_tests/at_commands_in_refs_latin1.pl
    trunk/tp/t/results/converters_tests/at_commands_in_refs_utf8.pl
    trunk/tp/t/results/coverage_braces/empty_commands.pl
    trunk/tp/t/results/coverage_braces/recursive_acronym.pl
    trunk/tp/t/results/menu/formats_in_menu.pl
    trunk/tp/t/results/plaintext_tests/at_commands_glued_in_example.pl
    trunk/tp/t/results/plaintext_tests/at_commands_glued_in_paragraph.pl
    trunk/tp/t/results/sectioning/non_automatic_internal_top_node_up.pl
    trunk/tp/t/results/sectioning/non_automatic_top_node_up_and_url.pl

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2016-05-28 21:31:35 UTC (rev 7194)
+++ trunk/ChangeLog     2016-05-29 13:30:10 UTC (rev 7195)
@@ -1,3 +1,12 @@
+2016-05-29  Gavin Smith  <address@hidden>
+
+       * tp/Texinfo/Parser.pm (_parse_texi) <@acronym, @abbr>: Don't
+       set 'explained_commands' hash or 'explanation_contents' extra 
+       value on elements.
+       * tp/Texinfo/Convert/HTML.pm (_convert_explained_command): Move 
+       the code for keeping track of previous acronym explanations
+       here.
+
 2016-05-28  Gavin Smith  <address@hidden>
 
        * tp/Texinfo/Parser.pm (_parse_texi) <@novalidate>,

Modified: trunk/tp/Texinfo/Convert/HTML.pm
===================================================================
--- trunk/tp/Texinfo/Convert/HTML.pm    2016-05-28 21:31:35 UTC (rev 7194)
+++ trunk/tp/Texinfo/Convert/HTML.pm    2016-05-29 13:30:10 UTC (rev 7195)
@@ -1478,17 +1478,48 @@
   my $args = shift;
 
   my $with_explanation;
+  my $explanation_result;
   my $explanation_string;
+  my $normalized_type
+    = Texinfo::Convert::NodeNameNormalization::normalize_node(
+    {'contents' =>
+      $command->{'extra'}->{'brace_command_contents'}->[0]});
+
   if ($args->[1] and defined($args->[1]->{'string'}) 
                  and $args->[1]->{'string'} =~ /\S/) {
     $with_explanation = 1;
     $explanation_string = $args->[1]->{'string'};
-  }
-  if ($command->{'extra'}->{'explanation_contents'}) {
+
+    # Convert the expanation of the acronym.  Must do this before we save
+    # the explanation for the future, otherwise we get infinite recursion
+    # for recursively-defined acronyms.
+    $explanation_result = $self->convert_tree( $args->[1]->{'tree'} );
+
+    $self->{'explained_commands'}->{$cmdname}->{$normalized_type} =
+       $command->{'extra'}->{'brace_command_contents'}->[1];
+  } elsif ($command->{'extra'}->{'explanation_contents'}) {
+    if (@{$command->{'extra'}->{'explanation_contents'}}) {
+      $explanation_string = $self->convert_tree_new_formatting_context(
+        {'type' => '_string', 
+         'contents' => $command->{'extra'}->{'explanation_contents'}},
+        $cmdname, $cmdname);
+    }
+  } elsif ($self->{'explained_commands'}->{$cmdname}->{$normalized_type}) {
     $explanation_string = $self->convert_tree_new_formatting_context(
       {'type' => '_string', 
-       'contents' => $command->{'extra'}->{'explanation_contents'}},
-      $cmdname, $cmdname);
+       'contents' => $self->{'explained_commands'}
+                       ->{$cmdname}->{$normalized_type}},
+    $cmdname, $cmdname);
+
+    $command->{'extra'}->{'explanation_contents'} 
+       = $self->{'explained_commands'}->{$cmdname}->{$normalized_type};
+  } else {
+    # Avoid ever giving an explanation for this element.  This prevents
+    # infinite recursion for a recursively-defined acronym, when an
+    # @acronym within the explanation could end up referring to the
+    # containing @acronym.
+
+    $command->{'extra'}->{'explanation_contents'} = [];
   }
   my $result = $args->[0]->{'normal'};
   if (!$self->in_string()) {
@@ -1503,8 +1534,10 @@
     $result = $self->convert_tree($self->gdt('{explained_string} 
({explanation})',
           {'explained_string' => {'type' => '_converted',
                    'text' => $result},
-           'explanation' => $args->[1]->{'tree'} }));
+           'explanation' => {'type' => '_converted',
+                   'text' => $explanation_result}}));
   }
+
   return $result;
 }
 

Modified: trunk/tp/Texinfo/Parser.pm
===================================================================
--- trunk/tp/Texinfo/Parser.pm  2016-05-28 21:31:35 UTC (rev 7194)
+++ trunk/tp/Texinfo/Parser.pm  2016-05-29 13:30:10 UTC (rev 7195)
@@ -5229,24 +5229,7 @@
                 $self->line_warn(
                    sprintf($self->__("address@hidden missing first argument"),
                            $current_command->{'cmdname'}), $line_nr);
-              } else {
-                if ($explained_commands{$current_command->{'cmdname'}}) {
-                  my $normalized_type
-                    = Texinfo::Convert::NodeNameNormalization::normalize_node(
-                        {'contents' =>
-                         
$current_command->{'extra'}->{'brace_command_contents'}->[0]});
-                  if 
(!$current_command->{'extra'}->{'brace_command_contents'}->[1]) {
-                    if 
($self->{'explained_commands'}->{$current_command->{'cmdname'}}->{$normalized_type})
 {
-                      $current_command->{'extra'}->{'explanation_contents'} 
-                        = 
$self->{'explained_commands'}->{$current_command->{'cmdname'}}->{$normalized_type};
-                    }
-                  } elsif (! _ignore_global_commands($self)) {
-                    
$self->{'explained_commands'}->{$current_command->{'cmdname'}}->{$normalized_type}
 
-                      = 
$current_command->{'extra'}->{'brace_command_contents'}->[1];
-                  }
-                }
               }
-
             } elsif ($current->{'parent'}->{'cmdname'} eq 'errormsg') {
               if (! _ignore_global_commands($self)) {
                 my $error_message_text 
@@ -7065,10 +7048,7 @@
 
 =item C<@acronym>
 
-The first argument normalized is in I<normalized>.  If there is no
-second argument, but a second argument appeared previously for the
-same first argument, the second argument content of the previous
-command is stored in I<explanation_contents>.
+The first argument normalized is in I<normalized>.
 
 =item definition command
 

Modified: trunk/tp/t/results/converters_tests/at_commands_in_raw.pl
===================================================================
--- trunk/tp/t/results/converters_tests/at_commands_in_raw.pl   2016-05-28 
21:31:35 UTC (rev 7194)
+++ trunk/tp/t/results/converters_tests/at_commands_in_raw.pl   2016-05-29 
13:30:10 UTC (rev 7195)
@@ -1874,7 +1874,8 @@
                   [
                     {}
                   ]
-                ]
+                ],
+                'explanation_contents' => []
               },
               'line_nr' => {
                 'file_name' => '',

Modified: trunk/tp/t/results/converters_tests/at_commands_in_refs.pl
===================================================================
--- trunk/tp/t/results/converters_tests/at_commands_in_refs.pl  2016-05-28 
21:31:35 UTC (rev 7194)
+++ trunk/tp/t/results/converters_tests/at_commands_in_refs.pl  2016-05-29 
13:30:10 UTC (rev 7195)
@@ -2720,7 +2720,8 @@
                           [
                             {}
                           ]
-                        ]
+                        ],
+                        'explanation_contents' => []
                       },
                       'line_nr' => {},
                       'parent' => {}
@@ -2879,7 +2880,8 @@
                           [
                             {}
                           ]
-                        ]
+                        ],
+                        'explanation_contents' => []
                       },
                       'line_nr' => {},
                       'parent' => {}
@@ -9358,7 +9360,8 @@
                   [
                     {}
                   ]
-                ]
+                ],
+                'explanation_contents' => []
               },
               'line_nr' => {},
               'parent' => {}
@@ -9509,7 +9512,8 @@
                   [
                     {}
                   ]
-                ]
+                ],
+                'explanation_contents' => []
               },
               'line_nr' => {},
               'parent' => {}
@@ -9662,7 +9666,8 @@
                   [
                     {}
                   ]
-                ]
+                ],
+                'explanation_contents' => []
               },
               'line_nr' => {},
               'parent' => {}
@@ -9813,7 +9818,8 @@
                   [
                     {}
                   ]
-                ]
+                ],
+                'explanation_contents' => []
               },
               'line_nr' => {},
               'parent' => {}
@@ -15162,7 +15168,8 @@
                           [
                             {}
                           ]
-                        ]
+                        ],
+                        'explanation_contents' => []
                       },
                       'line_nr' => {},
                       'parent' => {}
@@ -15309,7 +15316,8 @@
                           [
                             {}
                           ]
-                        ]
+                        ],
+                        'explanation_contents' => []
                       },
                       'line_nr' => {},
                       'parent' => {}

Modified: trunk/tp/t/results/converters_tests/at_commands_in_refs_latin1.pl
===================================================================
--- trunk/tp/t/results/converters_tests/at_commands_in_refs_latin1.pl   
2016-05-28 21:31:35 UTC (rev 7194)
+++ trunk/tp/t/results/converters_tests/at_commands_in_refs_latin1.pl   
2016-05-29 13:30:10 UTC (rev 7195)
@@ -2807,7 +2807,8 @@
                           [
                             {}
                           ]
-                        ]
+                        ],
+                        'explanation_contents' => []
                       },
                       'line_nr' => {},
                       'parent' => {}
@@ -2966,7 +2967,8 @@
                           [
                             {}
                           ]
-                        ]
+                        ],
+                        'explanation_contents' => []
                       },
                       'line_nr' => {},
                       'parent' => {}
@@ -9445,7 +9447,8 @@
                   [
                     {}
                   ]
-                ]
+                ],
+                'explanation_contents' => []
               },
               'line_nr' => {},
               'parent' => {}
@@ -9596,7 +9599,8 @@
                   [
                     {}
                   ]
-                ]
+                ],
+                'explanation_contents' => []
               },
               'line_nr' => {},
               'parent' => {}
@@ -9749,7 +9753,8 @@
                   [
                     {}
                   ]
-                ]
+                ],
+                'explanation_contents' => []
               },
               'line_nr' => {},
               'parent' => {}
@@ -9900,7 +9905,8 @@
                   [
                     {}
                   ]
-                ]
+                ],
+                'explanation_contents' => []
               },
               'line_nr' => {},
               'parent' => {}
@@ -15249,7 +15255,8 @@
                           [
                             {}
                           ]
-                        ]
+                        ],
+                        'explanation_contents' => []
                       },
                       'line_nr' => {},
                       'parent' => {}
@@ -15396,7 +15403,8 @@
                           [
                             {}
                           ]
-                        ]
+                        ],
+                        'explanation_contents' => []
                       },
                       'line_nr' => {},
                       'parent' => {}

Modified: trunk/tp/t/results/converters_tests/at_commands_in_refs_utf8.pl
===================================================================
--- trunk/tp/t/results/converters_tests/at_commands_in_refs_utf8.pl     
2016-05-28 21:31:35 UTC (rev 7194)
+++ trunk/tp/t/results/converters_tests/at_commands_in_refs_utf8.pl     
2016-05-29 13:30:10 UTC (rev 7195)
@@ -2807,7 +2807,8 @@
                           [
                             {}
                           ]
-                        ]
+                        ],
+                        'explanation_contents' => []
                       },
                       'line_nr' => {},
                       'parent' => {}
@@ -2966,7 +2967,8 @@
                           [
                             {}
                           ]
-                        ]
+                        ],
+                        'explanation_contents' => []
                       },
                       'line_nr' => {},
                       'parent' => {}
@@ -9445,7 +9447,8 @@
                   [
                     {}
                   ]
-                ]
+                ],
+                'explanation_contents' => []
               },
               'line_nr' => {},
               'parent' => {}
@@ -9596,7 +9599,8 @@
                   [
                     {}
                   ]
-                ]
+                ],
+                'explanation_contents' => []
               },
               'line_nr' => {},
               'parent' => {}
@@ -9749,7 +9753,8 @@
                   [
                     {}
                   ]
-                ]
+                ],
+                'explanation_contents' => []
               },
               'line_nr' => {},
               'parent' => {}
@@ -9900,7 +9905,8 @@
                   [
                     {}
                   ]
-                ]
+                ],
+                'explanation_contents' => []
               },
               'line_nr' => {},
               'parent' => {}
@@ -15249,7 +15255,8 @@
                           [
                             {}
                           ]
-                        ]
+                        ],
+                        'explanation_contents' => []
                       },
                       'line_nr' => {},
                       'parent' => {}
@@ -15396,7 +15403,8 @@
                           [
                             {}
                           ]
-                        ]
+                        ],
+                        'explanation_contents' => []
                       },
                       'line_nr' => {},
                       'parent' => {}

Modified: trunk/tp/t/results/coverage_braces/empty_commands.pl
===================================================================
--- trunk/tp/t/results/coverage_braces/empty_commands.pl        2016-05-28 
21:31:35 UTC (rev 7194)
+++ trunk/tp/t/results/coverage_braces/empty_commands.pl        2016-05-29 
13:30:10 UTC (rev 7195)
@@ -81,7 +81,8 @@
           'extra' => {
             'brace_command_contents' => [
               undef
-            ]
+            ],
+            'explanation_contents' => []
           },
           'line_nr' => {},
           'parent' => {}

Modified: trunk/tp/t/results/coverage_braces/recursive_acronym.pl
===================================================================
--- trunk/tp/t/results/coverage_braces/recursive_acronym.pl     2016-05-28 
21:31:35 UTC (rev 7194)
+++ trunk/tp/t/results/coverage_braces/recursive_acronym.pl     2016-05-29 
13:30:10 UTC (rev 7195)
@@ -48,7 +48,8 @@
                       [
                         {}
                       ]
-                    ]
+                    ],
+                    'explanation_contents' => []
                   },
                   'line_nr' => {
                     'file_name' => '',

Modified: trunk/tp/t/results/menu/formats_in_menu.pl
===================================================================
--- trunk/tp/t/results/menu/formats_in_menu.pl  2016-05-28 21:31:35 UTC (rev 
7194)
+++ trunk/tp/t/results/menu/formats_in_menu.pl  2016-05-29 13:30:10 UTC (rev 
7195)
@@ -603,7 +603,8 @@
                                 {},
                                 {}
                               ]
-                            ]
+                            ],
+                            'explanation_contents' => []
                           },
                           'line_nr' => {
                             'file_name' => '',

Modified: trunk/tp/t/results/plaintext_tests/at_commands_glued_in_example.pl
===================================================================
--- trunk/tp/t/results/plaintext_tests/at_commands_glued_in_example.pl  
2016-05-28 21:31:35 UTC (rev 7194)
+++ trunk/tp/t/results/plaintext_tests/at_commands_glued_in_example.pl  
2016-05-29 13:30:10 UTC (rev 7195)
@@ -171,8 +171,7 @@
                   [
                     {}
                   ]
-                ],
-                'explanation_contents' => []
+                ]
               },
               'line_nr' => {
                 'file_name' => '',
@@ -642,7 +641,6 @@
 
$result_trees{'at_commands_glued_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[13]{'args'}[0]{'contents'}[0]{'parent'}
 = 
$result_trees{'at_commands_glued_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[13]{'args'}[0];
 
$result_trees{'at_commands_glued_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[13]{'args'}[0]{'parent'}
 = 
$result_trees{'at_commands_glued_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[13];
 
$result_trees{'at_commands_glued_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[13]{'extra'}{'brace_command_contents'}[0][0]
 = 
$result_trees{'at_commands_glued_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[13]{'args'}[0]{'contents'}[0];
-$result_trees{'at_commands_glued_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[13]{'extra'}{'explanation_contents'}
 = 
$result_trees{'at_commands_glued_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[10]{'extra'}{'brace_command_contents'}[1];
 
$result_trees{'at_commands_glued_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[13]{'parent'}
 = $result_trees{'at_commands_glued_in_example'}{'contents'}[0]{'contents'}[1];
 
$result_trees{'at_commands_glued_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[14]{'parent'}
 = $result_trees{'at_commands_glued_in_example'}{'contents'}[0]{'contents'}[1];
 
$result_trees{'at_commands_glued_in_example'}{'contents'}[0]{'contents'}[1]{'contents'}[15]{'parent'}
 = $result_trees{'at_commands_glued_in_example'}{'contents'}[0]{'contents'}[1];

Modified: trunk/tp/t/results/plaintext_tests/at_commands_glued_in_paragraph.pl
===================================================================
--- trunk/tp/t/results/plaintext_tests/at_commands_glued_in_paragraph.pl        
2016-05-28 21:31:35 UTC (rev 7194)
+++ trunk/tp/t/results/plaintext_tests/at_commands_glued_in_paragraph.pl        
2016-05-29 13:30:10 UTC (rev 7195)
@@ -159,8 +159,7 @@
               [
                 {}
               ]
-            ],
-            'explanation_contents' => []
+            ]
           },
           'line_nr' => {
             'file_name' => '',
@@ -581,7 +580,6 @@
 
$result_trees{'at_commands_glued_in_paragraph'}{'contents'}[0]{'contents'}[13]{'args'}[0]{'contents'}[0]{'parent'}
 = 
$result_trees{'at_commands_glued_in_paragraph'}{'contents'}[0]{'contents'}[13]{'args'}[0];
 
$result_trees{'at_commands_glued_in_paragraph'}{'contents'}[0]{'contents'}[13]{'args'}[0]{'parent'}
 = 
$result_trees{'at_commands_glued_in_paragraph'}{'contents'}[0]{'contents'}[13];
 
$result_trees{'at_commands_glued_in_paragraph'}{'contents'}[0]{'contents'}[13]{'extra'}{'brace_command_contents'}[0][0]
 = 
$result_trees{'at_commands_glued_in_paragraph'}{'contents'}[0]{'contents'}[13]{'args'}[0]{'contents'}[0];
-$result_trees{'at_commands_glued_in_paragraph'}{'contents'}[0]{'contents'}[13]{'extra'}{'explanation_contents'}
 = 
$result_trees{'at_commands_glued_in_paragraph'}{'contents'}[0]{'contents'}[10]{'extra'}{'brace_command_contents'}[1];
 
$result_trees{'at_commands_glued_in_paragraph'}{'contents'}[0]{'contents'}[13]{'parent'}
 = $result_trees{'at_commands_glued_in_paragraph'}{'contents'}[0];
 
$result_trees{'at_commands_glued_in_paragraph'}{'contents'}[0]{'contents'}[14]{'parent'}
 = $result_trees{'at_commands_glued_in_paragraph'}{'contents'}[0];
 
$result_trees{'at_commands_glued_in_paragraph'}{'contents'}[0]{'contents'}[15]{'parent'}
 = $result_trees{'at_commands_glued_in_paragraph'}{'contents'}[0];

Modified: trunk/tp/t/results/sectioning/non_automatic_internal_top_node_up.pl
===================================================================
--- trunk/tp/t/results/sectioning/non_automatic_internal_top_node_up.pl 
2016-05-28 21:31:35 UTC (rev 7194)
+++ trunk/tp/t/results/sectioning/non_automatic_internal_top_node_up.pl 
2016-05-29 13:30:10 UTC (rev 7195)
@@ -94,7 +94,8 @@
                             [
                               {}
                             ]
-                          ]
+                          ],
+                          'explanation_contents' => []
                         },
                         'line_nr' => {
                           'file_name' => '',

Modified: trunk/tp/t/results/sectioning/non_automatic_top_node_up_and_url.pl
===================================================================
--- trunk/tp/t/results/sectioning/non_automatic_top_node_up_and_url.pl  
2016-05-28 21:31:35 UTC (rev 7194)
+++ trunk/tp/t/results/sectioning/non_automatic_top_node_up_and_url.pl  
2016-05-29 13:30:10 UTC (rev 7195)
@@ -94,7 +94,8 @@
                             [
                               {}
                             ]
-                          ]
+                          ],
+                          'explanation_contents' => []
                         },
                         'line_nr' => {
                           'file_name' => '',




reply via email to

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