| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::Amuse::Beamer; |
|
2
|
41
|
|
|
41
|
|
248
|
use strict; |
|
|
41
|
|
|
|
|
79
|
|
|
|
41
|
|
|
|
|
1109
|
|
|
3
|
41
|
|
|
41
|
|
181
|
use warnings; |
|
|
41
|
|
|
|
|
83
|
|
|
|
41
|
|
|
|
|
949
|
|
|
4
|
41
|
|
|
41
|
|
181
|
use utf8; |
|
|
41
|
|
|
|
|
68
|
|
|
|
41
|
|
|
|
|
200
|
|
|
5
|
|
|
|
|
|
|
# use Data::Dumper; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Text::Amuse::Beamer - Beamer output for Text::Amuse |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Parse the L LaTeX result and convert it to a |
|
14
|
|
|
|
|
|
|
beamer documentclass body, wrapping the text into frames. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
The module is used internally by L, so everything here is |
|
19
|
|
|
|
|
|
|
pretty much internal only (and underdocumented). |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 CONSTRUCTORS |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=over 4 |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=item new(latex => \@latex_chunks) |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=back |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=over 4 |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=item latex |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Accessor to the latex arrayref passed at the constructor. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=item process |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Return the beamer body as a string. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { |
|
44
|
1
|
|
|
1
|
1
|
5
|
my ($class, %args) = @_; |
|
45
|
1
|
50
|
|
|
|
5
|
die "Missing latex" unless $args{latex}; |
|
46
|
1
|
|
|
|
|
2
|
my $self = { latex => [ @{$args{latex}} ] }; |
|
|
1
|
|
|
|
|
26
|
|
|
47
|
1
|
|
|
|
|
6
|
bless $self, $class; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub latex { |
|
51
|
1
|
|
|
1
|
1
|
9
|
return shift->{latex}; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub process { |
|
55
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
|
56
|
1
|
|
|
|
|
6
|
my $latex = $self->latex; |
|
57
|
1
|
|
|
|
|
3
|
my @out; |
|
58
|
|
|
|
|
|
|
# these chunks correspond to the various elements found, so if |
|
59
|
|
|
|
|
|
|
# it's an heading, it's guaranteed to be this way. |
|
60
|
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
2
|
my ($in_frame, $in_text, @current, $current_title); |
|
62
|
|
|
|
|
|
|
# print Dumper($latex); |
|
63
|
1
|
|
|
|
|
4
|
foreach my $piece (@$latex) { |
|
64
|
121
|
|
|
|
|
159
|
$piece =~ s/\\footnoteB?\{/\\footnote[frame]{/g; |
|
65
|
121
|
100
|
|
|
|
251
|
if ($piece =~ /\A\s*\\( |
|
|
|
100
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
part| |
|
67
|
|
|
|
|
|
|
chapter| |
|
68
|
|
|
|
|
|
|
section| |
|
69
|
|
|
|
|
|
|
subsection| |
|
70
|
|
|
|
|
|
|
subsubsection) |
|
71
|
|
|
|
|
|
|
(\[\{(.+)\}\])? |
|
72
|
|
|
|
|
|
|
(\{(.+)\}\s*\z) |
|
73
|
|
|
|
|
|
|
/x) { |
|
74
|
15
|
|
|
|
|
26
|
my $type = $1; |
|
75
|
15
|
|
66
|
|
|
40
|
$in_frame = $3 || $5; |
|
76
|
15
|
100
|
|
|
|
25
|
if (@current) { |
|
77
|
8
|
|
50
|
|
|
52
|
push @out, { title => $current_title || '', |
|
78
|
|
|
|
|
|
|
body => [@current] }; |
|
79
|
8
|
|
|
|
|
14
|
@current = (); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
15
|
|
|
|
|
40
|
push @out, "\\" . $type . '{' . $in_frame . '}' . "\n\n"; |
|
82
|
15
|
|
|
|
|
23
|
$current_title = $in_frame; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
elsif (defined $in_frame) { |
|
85
|
105
|
|
|
|
|
149
|
push @current, $piece; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
# flush; |
|
89
|
1
|
50
|
33
|
|
|
8
|
if ($in_frame && @current) { |
|
90
|
0
|
|
|
|
|
0
|
push @out, { title => $current_title, |
|
91
|
|
|
|
|
|
|
body => [@current] }; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
1
|
|
|
|
|
7
|
return $self->_render(\@out); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub _render { |
|
97
|
1
|
|
|
1
|
|
3
|
my ($self, $list) = @_; |
|
98
|
1
|
|
|
|
|
3
|
my @out; |
|
99
|
|
|
|
|
|
|
ELEMENT: |
|
100
|
1
|
|
|
|
|
3
|
foreach my $el (@$list) { |
|
101
|
23
|
100
|
|
|
|
34
|
if (ref($el)) { |
|
102
|
8
|
|
|
|
|
10
|
my $body = join('', @{$el->{body}}); |
|
|
8
|
|
|
|
|
28
|
|
|
103
|
8
|
100
|
|
|
|
27
|
if ($body =~ m/^%\s+no\s*slides?\s*$/im) { |
|
104
|
|
|
|
|
|
|
# and remove the previous element with the chapter |
|
105
|
2
|
50
|
|
|
|
6
|
pop @out if @out; |
|
106
|
2
|
|
|
|
|
4
|
next ELEMENT; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
6
|
|
|
|
|
21
|
push @out, "\n\\begin{frame}[fragile]{$el->{title}}\n", $body, |
|
109
|
|
|
|
|
|
|
"\\end{frame}\n\n"; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
else { |
|
112
|
15
|
|
|
|
|
21
|
push @out, $el; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
} |
|
115
|
1
|
50
|
|
|
|
5
|
if (@out) { |
|
116
|
1
|
|
|
|
|
27
|
return join('', @out); |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
else { |
|
119
|
0
|
|
|
|
|
|
return ''; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=back |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
1; |