| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#=============================================================================== |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# DESCRIPTION: Latex writer |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# AUTHOR: Aliaksandr P. Zahatski, |
|
6
|
|
|
|
|
|
|
#=============================================================================== |
|
7
|
|
|
|
|
|
|
package Perl6::Pod::Writer::Latex; |
|
8
|
2
|
|
|
2
|
|
11
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
47
|
|
|
9
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
46
|
|
|
10
|
2
|
|
|
2
|
|
11
|
use Perl6::Pod::Writer; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
49
|
|
|
11
|
2
|
|
|
2
|
|
9
|
use base 'Perl6::Pod::Writer'; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
931
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
13
|
|
|
|
|
|
|
sub new { |
|
14
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
15
|
0
|
0
|
0
|
|
|
|
my $self = bless( ( $#_ == 0 ) ? shift : {@_}, ref($class) || $class ); |
|
16
|
0
|
|
|
|
|
|
$self; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub repl { |
|
20
|
0
|
|
|
0
|
0
|
|
my $str = shift; |
|
21
|
0
|
|
|
|
|
|
warn "!!$str"; |
|
22
|
0
|
|
|
|
|
|
my %map = ( |
|
23
|
|
|
|
|
|
|
'\\' =>'\textbackslash{}', |
|
24
|
|
|
|
|
|
|
'^' =>'\textbackslash{}', |
|
25
|
|
|
|
|
|
|
'~' => '\textasciitilde{}' |
|
26
|
|
|
|
|
|
|
#$txt =~ s/([#$%&_{}])/\\$1/g; |
|
27
|
|
|
|
|
|
|
); |
|
28
|
0
|
0
|
|
|
|
|
return $str if exists $map{$str}; |
|
29
|
0
|
|
|
|
|
|
return "\\$str" |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
#http://www.cespedes.org/blog/85/how-to-escape-latex-special-characters |
|
32
|
|
|
|
|
|
|
sub _latex_escape { |
|
33
|
0
|
|
|
0
|
|
|
my ( $txt ) =@_; |
|
34
|
|
|
|
|
|
|
#die "$txt"; |
|
35
|
|
|
|
|
|
|
#$txt = "#"; |
|
36
|
|
|
|
|
|
|
#warn ">$txt"; |
|
37
|
0
|
|
|
|
|
|
$txt =~ s/(\\|\^|\~|[\#\$\%\&\_\{\}])/&repl($1)/eg; |
|
|
0
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# $txt =~ s/\\/\textbackslash{}/g; |
|
39
|
|
|
|
|
|
|
# $txt =~ s/^/\textbackslash{}/g; |
|
40
|
|
|
|
|
|
|
# $txt =~ s/~/\textasciitilde{}/g; |
|
41
|
|
|
|
|
|
|
#$txt =~ s/([#$%&_{}])/\\$1/g; |
|
42
|
0
|
|
|
|
|
|
$txt |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub print { |
|
47
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
48
|
0
|
|
|
|
|
|
my $fh = $self->o; |
|
49
|
0
|
|
|
|
|
|
my $str = join ""=>@_; |
|
50
|
0
|
0
|
|
|
|
|
utf8::encode( $str) if utf8::is_utf8($str); |
|
51
|
0
|
|
|
|
|
|
print $fh _latex_escape($str); |
|
52
|
0
|
|
|
|
|
|
$self |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub start_nesting { |
|
56
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
57
|
0
|
|
0
|
|
|
|
my $level = shift || 1 ; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
sub stop_nesting { |
|
60
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
61
|
0
|
|
0
|
|
|
|
my $level = shift || 1 ; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|