| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Rhetoric::Formatters; |
|
2
|
1
|
|
|
1
|
|
3308
|
use common::sense; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
3
|
1
|
|
|
1
|
|
49
|
use aliased 'Squatting::H'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
|
|
use Try::Tiny; |
|
5
|
|
|
|
|
|
|
use Memoize; |
|
6
|
|
|
|
|
|
|
use Ouch; |
|
7
|
|
|
|
|
|
|
use Method::Signatures::Simple; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#memoize('_load'); |
|
10
|
|
|
|
|
|
|
sub _load { |
|
11
|
|
|
|
|
|
|
my $module = shift; |
|
12
|
|
|
|
|
|
|
my $formatter = shift; |
|
13
|
|
|
|
|
|
|
my $path = $module; |
|
14
|
|
|
|
|
|
|
$path =~ s{::}{/}g; |
|
15
|
|
|
|
|
|
|
$path .= ".pm"; |
|
16
|
|
|
|
|
|
|
my $module_loaded = 0; |
|
17
|
|
|
|
|
|
|
try { |
|
18
|
|
|
|
|
|
|
require($path); |
|
19
|
|
|
|
|
|
|
$module_loaded = 1; |
|
20
|
|
|
|
|
|
|
} catch { |
|
21
|
|
|
|
|
|
|
ouch('RequireFailed', "Could not load $module: $_"); |
|
22
|
|
|
|
|
|
|
}; |
|
23
|
|
|
|
|
|
|
return $formatter->() if $module_loaded; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $F = H->new({ |
|
27
|
|
|
|
|
|
|
raw => method($t) { |
|
28
|
|
|
|
|
|
|
$t |
|
29
|
|
|
|
|
|
|
}, |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
pod => method($t) { |
|
32
|
|
|
|
|
|
|
my $pod = _load('Pod::Simple::HTML', sub { |
|
33
|
|
|
|
|
|
|
my $pod = Pod::Simple::HTML->new; |
|
34
|
|
|
|
|
|
|
$pod->index(0); |
|
35
|
|
|
|
|
|
|
return $pod; |
|
36
|
|
|
|
|
|
|
}); |
|
37
|
|
|
|
|
|
|
my $out; |
|
38
|
|
|
|
|
|
|
$pod->output_string(\$out); |
|
39
|
|
|
|
|
|
|
$pod->parse_string_document("=pod\n\n$t\n\n=cut\n"); |
|
40
|
|
|
|
|
|
|
$out =~ s/^.*//s; |
|
41
|
|
|
|
|
|
|
$out =~ s/.*$//s; |
|
42
|
|
|
|
|
|
|
#$out =~ s/^(.*%3A%3A.*)$/my $x = $1; ($x =~ m{indexItem}) ? 1 : $x =~ s{%3A%3A}{\/}g; $x/gme; |
|
43
|
|
|
|
|
|
|
return $out; |
|
44
|
|
|
|
|
|
|
}, |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
textile => method($t) { |
|
47
|
|
|
|
|
|
|
my $tt = _load('Text::Textile', sub { |
|
48
|
|
|
|
|
|
|
return Text::Textile->new( |
|
49
|
|
|
|
|
|
|
disable_html => 1 |
|
50
|
|
|
|
|
|
|
); |
|
51
|
|
|
|
|
|
|
}); |
|
52
|
|
|
|
|
|
|
return $tt->process($t); |
|
53
|
|
|
|
|
|
|
}, |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
markdown => method($t) { |
|
56
|
|
|
|
|
|
|
my $md = _load('Text::Markdown', sub { |
|
57
|
|
|
|
|
|
|
# TODO - figure out what options we want to set for markdown |
|
58
|
|
|
|
|
|
|
return Text::Markdown->new(); |
|
59
|
|
|
|
|
|
|
}); |
|
60
|
|
|
|
|
|
|
return $md->markdown($t); |
|
61
|
|
|
|
|
|
|
}, |
|
62
|
|
|
|
|
|
|
}); |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |