| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Orze::Sources::Pandoc; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1742
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use base "Orze::Sources"; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
512
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Orze::Sources::Pandoc - Load a text file and render it as a html |
|
11
|
|
|
|
|
|
|
fragment using Pandoc. |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Load the file given in the C attribute and render it. It use |
|
16
|
|
|
|
|
|
|
L to do the actual processing. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
The default source and target are Markdown and HTML, but you can |
|
19
|
|
|
|
|
|
|
customize this behaviour using C and C attributes. |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
You can pass more options using the C attribute. Defaults are |
|
22
|
|
|
|
|
|
|
C<--reference-links> and C<--parse-raw>. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
The variant of Markdown used by Pandoc is more powerful than the |
|
25
|
|
|
|
|
|
|
standard one, read C. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Obviously, you will need Pandoc, available here: |
|
28
|
|
|
|
|
|
|
L |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 METHOD |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 evaluate |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub evaluate { |
|
37
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $page = $self->{page}; |
|
40
|
0
|
|
|
|
|
|
my $var = $self->{var}; |
|
41
|
0
|
|
|
|
|
|
my $file = $self->file(); |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $from = $page->att('from'); |
|
44
|
0
|
|
|
|
|
|
my $to = $page->att('to'); |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $options = $page->att('options'); |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
if (-r $file) { |
|
49
|
0
|
|
|
|
|
|
my $cmd = 'pandoc'; |
|
50
|
0
|
0
|
|
|
|
|
if (!$options) { |
|
51
|
0
|
|
|
|
|
|
$cmd .= ' --reference-links ' . |
|
52
|
|
|
|
|
|
|
'--parse-raw '; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
0
|
0
|
|
|
|
|
if ($from) { |
|
55
|
0
|
|
|
|
|
|
$cmd .= ' --from ' . $from; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
0
|
0
|
|
|
|
|
if ($to) { |
|
58
|
0
|
|
|
|
|
|
$cmd .= ' --to ' . $to; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
0
|
|
|
|
|
|
my $pandoc; |
|
61
|
|
|
|
|
|
|
{ |
|
62
|
1
|
|
|
1
|
|
7
|
no warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
152
|
|
|
|
0
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
open $pandoc, $cmd . ' ' . $file . ' |' |
|
64
|
|
|
|
|
|
|
or $self->warning("can't find pandoc"); |
|
65
|
0
|
|
|
|
|
|
my @lines = <$pandoc>; |
|
66
|
0
|
|
|
|
|
|
close $pandoc; |
|
67
|
0
|
|
|
|
|
|
my $html = join('', @lines); |
|
68
|
0
|
|
|
|
|
|
return $html; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
else { |
|
72
|
0
|
|
|
|
|
|
$self->warning('unable to read file ' . $file); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |