Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bestpractical/rt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Brandt <jbrandt@bestpractical.com>2022-11-04 20:50:41 +0300
committerJim Brandt <jbrandt@bestpractical.com>2022-11-04 22:09:14 +0300
commit91b804b245e8aec92a98b368c84a75ec8f6eeaed (patch)
tree6075be96f9f4c260e2d3b224cafe1fb64ea2495a
parentabe3ffa0d9c38cccc871d6e356ea9b73e2ab678b (diff)
Remove unwanted anchor tags from head elements5.0/convert-to-pod-simple
-rw-r--r--lib/RT/Shredder/POD.pm129
1 files changed, 129 insertions, 0 deletions
diff --git a/lib/RT/Shredder/POD.pm b/lib/RT/Shredder/POD.pm
index 70901bf69e..723f6e4d53 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) {
+ &Pod::Simple::HTML::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;