File: PerlTop.pm

package info (click to toggle)
libpod-tree-perl 1.31-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,020 kB
  • sloc: perl: 2,231; exp: 215; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 626 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package Pod::Tree::HTML::PerlTop;
use 5.006;
use strict;
use warnings;

use base qw(Pod::Tree::HTML);

our $VERSION = '1.31';

sub set_links {
	my ( $html, $links ) = @_;
	$html->{links} = $links;
}

sub _emit_verbatim {
	my ( $html, $node ) = @_;
	my $stream = $html->{stream};
	my $links  = $html->{links};
	my $text   = $node->get_text;

	$text =~ s( \n\n$ )()x;
	my @words = split m/(\s+)/, $text;

	$stream->PRE;

	for my $word (@words) {
		if ( $links->{$word} ) {
			my $link = $links->{$word};
			$stream->A( HREF => "$link.html" )->text($word)->_A;
		}
		else {
			$stream->text($word);
		}
	}

	$stream->_PRE;
}

1;