texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/Pod-Simple-Texinfo pod2texi.pl lib/Pod/...


From: Patrice Dumas
Subject: texinfo/Pod-Simple-Texinfo pod2texi.pl lib/Pod/...
Date: Sun, 26 Feb 2012 01:37:49 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        12/02/26 01:37:49

Modified files:
        Pod-Simple-Texinfo: pod2texi.pl 
        Pod-Simple-Texinfo/lib/Pod/Simple: Texinfo.pm 
        Pod-Simple-Texinfo/t: Pod-Simple-Texinfo.t 

Log message:
        Add the possibility to create nodes instead of anchors for sectioning
        commands.
        
        Add anchor or node for the top level added command.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/Pod-Simple-Texinfo/pod2texi.pl?cvsroot=texinfo&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/texinfo/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm?cvsroot=texinfo&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/texinfo/Pod-Simple-Texinfo/t/Pod-Simple-Texinfo.t?cvsroot=texinfo&r1=1.9&r2=1.10

Patches:
Index: pod2texi.pl
===================================================================
RCS file: /sources/texinfo/texinfo/Pod-Simple-Texinfo/pod2texi.pl,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- pod2texi.pl 11 Feb 2012 22:45:43 -0000      1.11
+++ pod2texi.pl 26 Feb 2012 01:37:48 -0000      1.12
@@ -72,6 +72,7 @@
 
 Options:
     --base-level=NUM|NAME   level of the head1 commands.
+    --section-nodes         add nodes for sections instead of anchors.
     --output=NAME           output to <NAME> for the first or the main manual
                             instead of standard out.
     --subdir=NAME           put files included in the main manual in <NAME>.
@@ -85,6 +86,7 @@
 my $output = '-';
 my $top = 'top';
 my $subdir;
+my $section_nodes = 0;
 
 my $result_options = Getopt::Long::GetOptions (
   'help|h' => sub { print pod2texi_help(); exit 0; },
@@ -108,6 +110,7 @@
   'output|o=s' => \$output,
   'subdir=s' => \$subdir,
   'top=s' => \$top,
+  'section-nodes!' => \$section_nodes,
 );
 
 exit 1 if (!$result_options);
@@ -209,6 +212,9 @@
   binmode($fh, ':encoding(utf8)');
   $new->output_fh($fh);
   $new->texinfo_sectioning_base_level($base_level);
+  if ($section_nodes) {
+    $new->texinfo_section_nodes(1);
+  }
   if ($unnumbered_sections) {
     $new->texinfo_sectioning_style('unnumbered');
   }
@@ -335,6 +341,10 @@
 Name for the first manual, or the main manual if there is a main manual.
 Default is output on standard out.
 
+=item B<--section-nodes>
+
+Add a node for each section instead of an anchor.
+
 =item B<--subdir>=I<NAME>
 
 If there is a main manual with include files, each corresponding to

Index: lib/Pod/Simple/Texinfo.pm
===================================================================
RCS file: 
/sources/texinfo/texinfo/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- lib/Pod/Simple/Texinfo.pm   11 Feb 2012 20:30:25 -0000      1.13
+++ lib/Pod/Simple/Texinfo.pm   26 Feb 2012 01:37:48 -0000      1.14
@@ -68,6 +68,7 @@
   'texinfo_man_url_prefix',
   'texinfo_sectioning_style',
   'texinfo_add_upper_sectioning_command',
+  'texinfo_section_nodes',
   'texinfo_internal_pod_manuals',
 );
 
@@ -82,6 +83,7 @@
   my $new = $class->SUPER::new(@_);
   $new->accept_targets(@raw_formats);
   $new->preserve_whitespace(1);
+  $new->texinfo_section_nodes(0);
   $new->texinfo_sectioning_base_level ($sectioning_base_level);
   $new->texinfo_man_url_prefix ($man_url_prefix);
   $new->texinfo_sectioning_style ($sectioning_style);
@@ -192,8 +194,20 @@
   } elsif (defined($self->texinfo_short_title)
            and $self->texinfo_add_upper_sectioning_command) {
       my $level = $self->texinfo_sectioning_base_level() - 1;
-      print $fh "address@hidden>{'texinfo_sectioning_commands'}->[$level] "
-         ._protect_text($self->texinfo_short_title, 1)."\n\n";
+      my $name = _protect_text($self->texinfo_short_title, 1);
+      my $node_name = _prepare_anchor($self, $name);
+
+      my $anchor = '';
+      my $node = '';
+      if ($node_name =~ /\S/) {
+        if (!$self->texinfo_section_nodes) {
+          $anchor = "address@hidden";
+        } else {
+          $node = "address@hidden $node_name\n";
+        }
+      }
+      print $fh "address@hidden>{'texinfo_sectioning_commands'}->[$level] "
+         ._protect_text($self->texinfo_short_title, 1)."\n$anchor\n";
   }
 }
 
@@ -317,7 +331,7 @@
   return $result;
 }
 
-sub _prepare_anchor($$)
+sub _node_name($$)
 {
   my $self = shift;
   my $texinfo_node_name = shift;
@@ -327,6 +341,13 @@
      = $self->_section_manual_to_node_name($self->texinfo_short_title,
                                           $texinfo_node_name,
                                           
$self->texinfo_sectioning_base_level);
+  return $texinfo_node_name;
+}
+
+sub _prepare_anchor($$)
+{
+  my $self = shift;
+  my $texinfo_node_name = shift;
 
   my $node = _normalize_texinfo_name($texinfo_node_name, 'anchor');
 
@@ -549,7 +570,7 @@
         $text = _protect_text($token->text());
         if (@format_stack and !ref($format_stack[-1])
             and ($self->{'texinfo_raw_format_commands'}->{$format_stack[-1]})) 
{
-          $text =~ s/^(\s*)#(\s*(line)? (\d+)( 
"([^"]+)")?(\s+\d+)*\s*)$/address@hidden/mg;
+          $text =~ s/^(\s*)#(\s*(line)? (\d+)(( 
"([^"]+)")(\s+\d+)*)?\s*)$/address@hidden/mg;
         }
       }
       _output($fh, address@hidden, $text);
@@ -557,6 +578,7 @@
       my $tagname = $token->tagname();
       if ($context_tags{$tagname}) {
         my ($result, $out) = _end_context(address@hidden);
+        my $texinfo_node = '';
         if ($line_commands{$tagname}) {
 
           my ($command, $command_argument);
@@ -580,20 +602,21 @@
               $command_argument = 
_protect_text($converter->convert_tree($tree));
             }
 
-            my $node_name = _prepare_anchor ($self, $result);
-            #print $fh "address@hidden $node_name\n";
-            my $anchor;
+            my $anchor = '';
+            my $node_name = _prepare_anchor ($self, _node_name($self,$result));
             if ($node_name =~ /\S/) {
-              $anchor = "address@hidden";
+              if ($tagname eq 'item-text' or !$self->texinfo_section_nodes) {
+                $anchor = "address@hidden";
             } else {
-              $anchor = '';
+                $texinfo_node = "address@hidden $node_name\n";
             }
-            $command_argument .= "\n$anchor";
+            }
+            $command_argument .= $anchor;
           } else {
             $command_argument = $result;
           }
           _output($fh, address@hidden, 
-                  "address@hidden $command_argument\n$out\n");
+                  "address@hidden $command_argument\n$out\n");
         } elsif ($tagname eq 'Para') {
           _output($fh, address@hidden, $out.
                                    _protect_hashchar($result)."\n\n");
@@ -747,6 +770,10 @@
 to 2 and so on and so forth.  If the base level is 0, a C<@top> command is 
 output instead.
 
+=item texinfo_section_nodes
+
+If set, add C<@node> and not C<@anchor> for each sectioning command.
+
 =back
 
 =head1 SEE ALSO

Index: t/Pod-Simple-Texinfo.t
===================================================================
RCS file: /sources/texinfo/texinfo/Pod-Simple-Texinfo/t/Pod-Simple-Texinfo.t,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- t/Pod-Simple-Texinfo.t      11 Feb 2012 20:30:25 -0000      1.9
+++ t/Pod-Simple-Texinfo.t      26 Feb 2012 01:37:49 -0000      1.10
@@ -107,7 +107,6 @@
 ', '@table @asis
 @item @ref{somewhere}
 
-
 @end table
 
 ', 'ref in item');
@@ -133,7 +132,6 @@
 run_test('=head1 L</somewhere>
 ', '@chapter somewhere
 
-
 ', 'ref in section');
 
 run_test('=over



reply via email to

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