File: Pre.pm

package info (click to toggle)
libtext-trac-perl 0.24-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 712 kB
  • sloc: perl: 1,462; makefile: 10
file content (41 lines) | stat: -rwxr-xr-x 650 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
40
41
package Text::Trac::Pre;

use strict;
use warnings;
use base qw(Text::Trac::BlockNode);

our $VERSION = '0.24';

sub init {
	my $self = shift;
	$self->pattern(qr/^\{\{\{$/xms);
	return $self;
}

sub parse {
	my ( $self, $l ) = @_;
	my $c       = $self->{context};
	my $pattern = $self->pattern;
	$l =~ /$pattern/ or return $l;
	my $match = $1;
	my $class = $c->{class} ? q{ class="wiki"} : '';

	if ( $l =~ /^\{\{\{$/ ) {
		$c->htmllines(qq{<pre$class>});
	}

	while ( $c->hasnext ) {
		my $l = $c->shiftline;
		if ( $l =~ /^\}\}\}$/ ) {
			$c->htmllines('</pre>');
			last;
		}
		else {
			$c->htmllines( $self->escape($l) );
		}
	}

	return;
}

1;