[Rt-commit] rt branch 5.0/convert-to-pod-simple updated. rt-5.0.3-130-g8020bbf780

BPS Git Server git at git.bestpractical.com
Fri Nov 4 17:51:18 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/convert-to-pod-simple has been updated
       via  8020bbf78044f20cb17daec2c66c0304fe1eb89f (commit)
       via  abe3ffa0d9c38cccc871d6e356ea9b73e2ab678b (commit)
      from  88991e184710d65a2d31e0937a651a9425d8ffaf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8020bbf78044f20cb17daec2c66c0304fe1eb89f
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Nov 4 13:50:41 2022 -0400

    Remove unwanted anchor tags from head elements

diff --git a/lib/RT/Shredder/POD.pm b/lib/RT/Shredder/POD.pm
index 70901bf69e..6eb9b889b5 100644
--- a/lib/RT/Shredder/POD.pm
+++ b/lib/RT/Shredder/POD.pm
@@ -276,4 +276,133 @@ sub version_tag_comment {
     # Don't need version details inside the RT HTML page.
     return '';
 }
+
+# This override is to remove the links around head elements since we
+# don't have an index and they aren't used in the RT page.
+
+# Would prefer not to copy this entire method for this small change
+# but it's embedded in the logic.
+
+# TODO: remove this if Pod::Simple::HTML adds a way to suppress
+# the links via config somehow
+
+$Pod::Simple::HTML::Tagmap{'no-a/head1'} = "</h1>\n";
+$Pod::Simple::HTML::Tagmap{'no-a/head2'} = "</h2>\n";
+$Pod::Simple::HTML::Tagmap{'no-a/head3'} = "</h3>\n";
+$Pod::Simple::HTML::Tagmap{'no-a/head4'} = "</h4>\n";
+$Pod::Simple::HTML::Tagmap{'no-a/head5'} = "</h5>\n";
+$Pod::Simple::HTML::Tagmap{'no-a/head6'} = "</h6>\n";
+
+sub _do_middle_main_loop {
+  my $self = $_[0];
+  my $fh = $self->{'output_fh'};
+  my $tagmap = $self->{'Tagmap'};
+
+  $self->__adjust_html_h_levels;
+
+  my($token, $type, $tagname, $linkto, $linktype);
+  my @stack;
+  my $dont_wrap = 0;
+
+  while($token = $self->get_token) {
+
+    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+    if( ($type = $token->type) eq 'start' ) {
+      if(($tagname = $token->tagname) eq 'L') {
+        $linktype = $token->attr('type') || 'insane';
+
+        $linkto = $self->do_link($token);
+
+        if(defined $linkto and length $linkto) {
+          esc($linkto);
+            #   (Yes, SGML-escaping applies on top of %-escaping!
+            #   But it's rarely noticeable in practice.)
+          print $fh qq{<a href="$linkto" class="podlink$linktype"\n>};
+        } else {
+          print $fh "<a>"; # Yes, an 'a' element with no attributes!
+        }
+
+      } elsif ($tagname eq 'item-text' or $tagname =~ m/^head\d$/s) {
+        print $fh $tagmap->{$tagname} || next;
+
+        my @to_unget;
+        while(1) {
+          push @to_unget, $self->get_token;
+          last if $to_unget[-1]->is_end
+              and $to_unget[-1]->tagname eq $tagname;
+
+          # TODO: support for X<...>'s found in here?  (maybe hack into linearize_tokens)
+        }
+
+        my $name = $self->linearize_tokens(@to_unget);
+        $name = $self->do_section($name, $token) if defined $name;
+
+        # Code that adds anchor tags to head elements removed here
+
+        $self->unget_token(@to_unget);
+
+      } elsif ($tagname eq 'Data') {
+        my $next = $self->get_token;
+        next unless defined $next;
+        unless( $next->type eq 'text' ) {
+          $self->unget_token($next);
+          next;
+        }
+        &Pod::Simple::DEBUG and print STDERR "    raw text ", $next->text, "\n";
+        # The parser sometimes preserves newlines and sometimes doesn't!
+        (my $text = $next->text) =~ s/\n\z//;
+        print $fh $text, "\n";
+        next;
+
+      } else {
+        if( $tagname =~ m/^over-/s ) {
+          push @stack, '';
+        } elsif( $tagname =~ m/^item-/s and @stack and $stack[-1] ) {
+          print $fh $stack[-1];
+          $stack[-1] = '';
+        }
+        print $fh $tagmap->{$tagname} || next;
+        ++$dont_wrap if $tagname eq 'Verbatim' or $tagname eq "VerbatimFormatted"
+          or $tagname eq 'X';
+      }
+
+    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+    } elsif( $type eq 'end' ) {
+      if( ($tagname = $token->tagname) =~ m/^over-/s ) {
+        if( my $end = pop @stack ) {
+          print $fh $end;
+        }
+      } elsif( $tagname =~ m/^item-/s and @stack) {
+        $stack[-1] = $tagmap->{"/$tagname"};
+        if( $tagname eq 'item-text' and defined(my $next = $self->get_token) ) {
+          $self->unget_token($next);
+          if( $next->type eq 'start' ) {
+            print $fh $tagmap->{"/item-text"},$tagmap->{"item-body"};
+            $stack[-1] = $tagmap->{"/item-body"};
+          }
+        }
+        next;
+      }
+
+      if ($tagname =~ m/^head\d$/s) {
+          print $fh $tagmap->{"no-a/$tagname"} || next;
+      }
+      else {
+          print $fh $tagmap->{"/$tagname"} || next;
+      }
+
+      --$dont_wrap if $tagname eq 'Verbatim' or $tagname eq 'X';
+
+    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+    } elsif( $type eq 'text' ) {
+      &Pod::Simple::HTML::esc($type = $token->text);  # reuse $type, why not
+      $type =~ s/([\?\!\"\'\.\,]) /$1\n/g unless $dont_wrap;
+      print $fh $type;
+    }
+
+  }
+  return 1;
+}
+
+
 1;

commit abe3ffa0d9c38cccc871d6e356ea9b73e2ab678b
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Nov 4 13:49:32 2022 -0400

    Clear unneeded anchors and HTML comments

diff --git a/lib/RT/Shredder/POD.pm b/lib/RT/Shredder/POD.pm
index fe10ae16bb..70901bf69e 100644
--- a/lib/RT/Shredder/POD.pm
+++ b/lib/RT/Shredder/POD.pm
@@ -56,6 +56,7 @@ sub plugin_html
 {
     my ($file, $out_fh) = @_;
     my $parser = RT::Shredder::POD::HTML->new;
+    $parser->top_anchor('');
     $parser->output_fh($out_fh);
     $parser->select('SYNOPSIS', 'ARGUMENTS', 'USAGE');
     $parser->parse_file( $file );
@@ -95,6 +96,7 @@ sub arguments_help {
 
     my $text;
     my $parser = RT::Shredder::POD::HTML->new;
+    $parser->top_anchor('');
     $parser->output_string(\$text);
     $parser->select('ARGUMENTS');
     $parser->parse_file( $file );
@@ -270,4 +272,8 @@ sub get_token {
     return $token;
 }
 
+sub version_tag_comment {
+    # Don't need version details inside the RT HTML page.
+    return '';
+}
 1;

-----------------------------------------------------------------------

Summary of changes:
 lib/RT/Shredder/POD.pm | 135 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 135 insertions(+)


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list