texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/Pod-Simple-Texinfo lib/Pod/Simple/Texin...


From: Patrice Dumas
Subject: texinfo/Pod-Simple-Texinfo lib/Pod/Simple/Texin...
Date: Sat, 28 Jan 2012 17:53:25 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        12/01/28 17:53:25

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

Log message:
        Better normalization of anchors, and try to fix the anchors as there may
        be @ref, for instance in Pod.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm?cvsroot=texinfo&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/texinfo/Pod-Simple-Texinfo/t/Pod-Simple-Texinfo.t?cvsroot=texinfo&r1=1.2&r2=1.3

Patches:
Index: lib/Pod/Simple/Texinfo.pm
===================================================================
RCS file: 
/sources/texinfo/texinfo/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- lib/Pod/Simple/Texinfo.pm   22 Jan 2012 00:26:05 -0000      1.5
+++ lib/Pod/Simple/Texinfo.pm   28 Jan 2012 17:53:25 -0000      1.6
@@ -29,7 +29,7 @@
 use Pod::Simple::PullParser ();
 
 use Texinfo::Convert::NodeNameNormalization qw(normalize_node);
-use Texinfo::Parser qw(parse_texi_line);
+use Texinfo::Parser qw(parse_texi_line parse_texi_text);
 use Texinfo::Convert::Texinfo;
 use Texinfo::Common qw(protect_comma_in_tree);
 
@@ -288,7 +288,18 @@
                                           $texinfo_node_name,
                                           
$self->texinfo_sectioning_base_level);
 
-  my $node_tree = parse_texi_line(undef, $texinfo_node_name);
+  # Pod may be more forgiven than Texinfo, so we go through
+  # a normalization, by parsing and converting back to Texinfo
+  my $anchor_tree = parse_texi_text(undef, "address@hidden");
+  my $anchor = Texinfo::Convert::Texinfo::convert($anchor_tree, 1);
+  my $node = $anchor;
+  $node =~ s/address@hidden(.*)\}$/$1/s;
+
+  if ($node !~ /\S/) {
+    return '';
+  }
+  # Now we know that we have something.
+  my $node_tree = parse_texi_line(undef, $node);
   my $normalized_base = normalize_node($node_tree);
   my $normalized = $normalized_base;
   my $number_appended = 0;
@@ -303,7 +314,8 @@
   }
   $node_tree = protect_comma_in_tree(undef, $node_tree);
   $self->{'texinfo_nodes'}->{$normalized} = $node_tree;
-  return Texinfo::Convert::Texinfo::convert($node_tree);
+  my $final_node_name = Texinfo::Convert::Texinfo::convert($node_tree, 1);
+  return $final_node_name;
 }
 
 # from Pod::Simple::HTML general_url_escape
@@ -387,6 +399,10 @@
           if ($linktype eq 'man') {
             # NOTE: the .'' is here to force the $token->attr to ba a real
             # string and not an object.
+            # NOTE 2: It is not clear that setting the url should be done
+            # here, maybe this should be in the Texinfo HTML converter.
+            # However, there is a 'man' category here and not in Texinfo,
+            # so the information is more precise in pod.
             my $replacement_arg = $token->attr('to').'';
             # regexp from Pod::Simple::HTML resolve_man_page_link
             # since it is very small, it is likely that copyright cannot be
@@ -495,9 +511,17 @@
           if ($head_commands_level{$tagname} or $tagname eq 'item-text') {
             chomp ($result);
             $result =~ s/\n/ /g;
+            $result =~ s/^\s*//;
+            $result =~ s/\s*$//;
             my $node_name = _prepare_anchor ($self, $result);
             #print $fh "address@hidden $node_name\n";
-            $result .= "address@hidden";
+            my $anchor;
+            if ($node_name =~ /\S/) {
+              $anchor = "address@hidden";
+            } else {
+              $anchor = '';
+            }
+            $result .= "\n$anchor";
           }
           _output($fh, address@hidden, "address@hidden $result\n$out\n");
         } elsif ($tagname eq 'Para') {

Index: t/Pod-Simple-Texinfo.t
===================================================================
RCS file: /sources/texinfo/texinfo/Pod-Simple-Texinfo/t/Pod-Simple-Texinfo.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- t/Pod-Simple-Texinfo.t      21 Jan 2012 22:39:34 -0000      1.2
+++ t/Pod-Simple-Texinfo.t      28 Jan 2012 17:53:25 -0000      1.3
@@ -6,7 +6,7 @@
 # change 'tests => 1' to 'tests => last_test_to_print';
 
 use Test::More;
-BEGIN { plan tests => 4 };
+BEGIN { plan tests => 7 };
 use Pod::Simple::Texinfo;
 ok(1); # If we made it this far, we're ok.
 
@@ -101,5 +101,35 @@
 
 ', 'index in item-text');
 
+run_test('=over
+
+=item L</somewhere>
+', '@table @asis
address@hidden @ref{somewhere}
+
+
address@hidden table
+
+', 'ref in item');
+
+run_test('=head1 NAME
+
+=head1 NAME 
+', '@chapter NAME
address@hidden
+
address@hidden NAME
address@hidden 1}
+
+', 'double ref');
+
+run_test('=head1 head with
+new line
+', '@chapter head with new line
address@hidden with new line}
+
+', 'head with new line');
+
+
 1;
 



reply via email to

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