| 1 | package MKDoc::Text::Structured::PRE; | ||||||||||
| 2 | 20 | ▶ | use base qw /MKDoc::Text::Structured::Base/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 20 | ▶ | use MKDoc::Text::Structured::Inline; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 20 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 20 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | |||||||||||
| 8 | sub new | ||||||||||
| 9 | 258 | ▶ | { | ||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 10 | 258 | my $class = shift; | |||||||||
| 11 | 258 | my $line = shift; | |||||||||
| 12 | |||||||||||
| 13 | 258 | ▶ | $line =~ s/^\s*$// and return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | |||||||||||
| 15 | 216 | my ($indent) = $line =~ /^(\s+)/; | |||||||||
| 16 | 216 | ▶ | return unless ($indent); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | |||||||||||
| 18 | 11 | my $self = $class->SUPER::new(); | |||||||||
| 19 | 11 | $self->{indent} = $indent; | |||||||||
| 20 | 11 | return $self; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | sub is_ok | ||||||||||
| 25 | 22 | ▶ | { | ||||||||
|
Subroutine
is_ok: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 26 | 22 | my $self = shift; | |||||||||
| 27 | 22 | my $line = shift; | |||||||||
| 28 | 22 | return $line =~ /^\s/; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | |||||||||||
| 32 | sub process | ||||||||||
| 33 | 9 | ▶ | { | ||||||||
|
Subroutine
process: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 34 | 9 | my $self = shift; | |||||||||
| 35 | 9 | my @lines = @{$self->{lines}}; | |||||||||
| 36 | 9 | my $indent = $self->{indent}; | |||||||||
| 37 | 9 | for (@lines) | |||||||||
| 38 | { | ||||||||||
| 39 | 15 | my ($_indent) = $_ =~ /^(\s+)/; | |||||||||
| 40 | 15 | ▶ | $indent = $_indent if (length ($_indent) lt length ($indent)); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | } | ||||||||||
| 42 | 9 | my $text = join "\n", map { s/^$indent//; $_ } @lines; | |||||||||
| 43 | |||||||||||
| 44 | # minimal encoding since we don't want all | ||||||||||
| 45 | # the inline fluff | ||||||||||
| 46 | 9 | $text =~ s/&/&/g; | |||||||||
| 47 | 9 | $text =~ s/</</g; | |||||||||
| 48 | 9 | $text =~ s/>/>/g; | |||||||||
| 49 | |||||||||||
| 50 | 9 | return "<pre>$text</pre>"; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | |||||||||||
| 54 | 20 | 1; | |||||||||
| 55 | |||||||||||
| 56 | |||||||||||
| 57 | __END__ | ||||||||||