line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Markdown::Slidy; |
2
|
2
|
|
|
2
|
|
30818
|
use 5.008001; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
86
|
|
3
|
2
|
|
|
2
|
|
14
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
85
|
|
4
|
2
|
|
|
2
|
|
22
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
111
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
7
|
2
|
|
|
2
|
|
1982
|
use parent 'Exporter'; |
|
2
|
|
|
|
|
669
|
|
|
2
|
|
|
|
|
11
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw/markdown split_markdown/; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
1
|
|
|
1
|
1
|
3
|
my $class = shift; |
13
|
1
|
50
|
|
|
|
5
|
my %args = @_ == 1 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
0
|
|
14
|
1
|
|
|
|
|
4
|
bless {%args}, $class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub markdown { |
18
|
2
|
|
|
2
|
1
|
3
|
my ($self, $text) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Detect functional mode, and create an instance for this run |
21
|
2
|
100
|
|
|
|
6
|
unless (ref $self) { |
22
|
1
|
50
|
|
|
|
5
|
if ( $self ne __PACKAGE__ ) { |
23
|
1
|
|
|
|
|
11
|
my $ob = __PACKAGE__->new(); |
24
|
|
|
|
|
|
|
# $self is text, $text is options |
25
|
1
|
|
|
|
|
6
|
return $ob->markdown($self, $text); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else { |
28
|
0
|
|
|
|
|
0
|
croak('Calling ' . $self . '->markdown (as a class method) is not supported.'); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
1
|
|
|
|
|
4
|
my @slides = $self->_sections($text); |
32
|
1
|
|
|
|
|
26
|
join "\n", @slides; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub template { |
36
|
2
|
|
|
2
|
0
|
4
|
my $self = shift; |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
100
|
|
|
23
|
$self->{template} ||= qq[ \n%s \n]; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub md { |
42
|
2
|
|
|
2
|
0
|
5
|
my $self = shift; |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
66
|
|
|
15
|
$self->{md} ||= do { |
45
|
1
|
|
|
|
|
1721
|
require Text::Markdown; |
46
|
1
|
|
|
|
|
47090
|
Text::Markdown->new; |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _process { |
51
|
2
|
|
|
2
|
|
4
|
my ($self, $slide_text) = @_; |
52
|
|
|
|
|
|
|
|
53
|
2
|
|
|
|
|
4
|
my $html = $self->md->markdown($slide_text); |
54
|
2
|
|
|
|
|
3854
|
sprintf $self->template, $html; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _sections { |
58
|
1
|
|
|
1
|
|
3
|
my ($self, $text) = @_; |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
4
|
map {$self->_process($_)} split_markdown($text); |
|
2
|
|
|
|
|
8
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub split_markdown { |
64
|
2
|
|
|
2
|
1
|
10
|
my $text = shift; |
65
|
2
|
|
|
|
|
14
|
$text =~ s/^\A\s+//ms; |
66
|
2
|
|
|
|
|
16
|
$text =~ s/\s+\z//ms; |
67
|
|
|
|
|
|
|
|
68
|
2
|
|
|
|
|
4
|
my @slides; |
69
|
|
|
|
|
|
|
my @slide_lines; |
70
|
0
|
|
|
|
|
0
|
my $prev; |
71
|
2
|
|
|
|
|
25
|
for my $line (split /\r?\n/, $text) { |
72
|
16
|
100
|
66
|
|
|
56
|
if ( $line =~ /^(?:(?:-+)|(?:=+))$/ && $prev) { |
73
|
4
|
|
|
|
|
4
|
pop @slide_lines; |
74
|
4
|
100
|
|
|
|
16
|
push @slides, join("\n", @slide_lines) if @slide_lines; |
75
|
4
|
|
|
|
|
8
|
@slide_lines = ($prev); # $prev is title; |
76
|
|
|
|
|
|
|
} |
77
|
16
|
|
|
|
|
17
|
push @slide_lines, $line; |
78
|
16
|
|
|
|
|
18
|
$prev = $line; |
79
|
|
|
|
|
|
|
} |
80
|
2
|
50
|
|
|
|
9
|
push @slides, join("\n", @slide_lines) if @slide_lines; |
81
|
|
|
|
|
|
|
|
82
|
2
|
|
|
|
|
14
|
@slides; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
__END__ |