line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/env perl |
2
|
|
|
|
|
|
|
# Copyright (c) 2014, 2015 Yon |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Permission to use, copy, modify, and distribute this software for any |
5
|
|
|
|
|
|
|
# purpose with or without fee is hereby granted, provided that the above |
6
|
|
|
|
|
|
|
# copyright notice and this permission notice appear in all copies. |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
9
|
|
|
|
|
|
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
10
|
|
|
|
|
|
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
11
|
|
|
|
|
|
|
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
12
|
|
|
|
|
|
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
13
|
|
|
|
|
|
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
14
|
|
|
|
|
|
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
# Object interface for use in user macros and filters |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
package Text::Frundis::Object; |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
3
|
|
10
|
use utf8; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
11
|
|
22
|
3
|
|
|
3
|
|
75
|
use v5.12; |
|
3
|
|
|
|
|
6
|
|
23
|
3
|
|
|
3
|
|
9
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
48
|
|
24
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
61
|
|
25
|
3
|
|
|
3
|
|
8
|
use open qw(:std :utf8); |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
13
|
|
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
3
|
|
271
|
use Exporter 'import'; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
64
|
|
28
|
3
|
|
|
3
|
|
8
|
use Text::Frundis::Processing; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
2661
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our @Arg; # Macro line arguments (so common that a global variable is handy) |
31
|
|
|
|
|
|
|
our @EXPORT_OK = qw(@Arg); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub new { # [[[ |
34
|
60
|
|
|
60
|
0
|
75
|
my $class = shift; |
35
|
60
|
|
|
|
|
59
|
my $self = shift; |
36
|
60
|
|
|
|
|
140
|
bless $self, $class; |
37
|
|
|
|
|
|
|
} # ]]] |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# methods, in alphabetic order |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub args { # [[[ |
42
|
4
|
|
|
4
|
0
|
6
|
shift; |
43
|
4
|
|
|
|
|
19
|
return \@Arg; |
44
|
|
|
|
|
|
|
} # ]]] |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub call { # [[[ |
47
|
12
|
|
|
12
|
0
|
17
|
shift; |
48
|
12
|
|
|
|
|
30
|
Text::Frundis::Processing::call(@_); |
49
|
|
|
|
|
|
|
} # ]]] |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _call_perl_macro { # [[[ |
52
|
86
|
|
|
86
|
|
76
|
my $self = shift; |
53
|
86
|
|
|
|
|
55
|
my $macro = shift; |
54
|
86
|
|
|
|
|
1129
|
$self->{macros}{$macro}{code}->($self); |
55
|
|
|
|
|
|
|
} # ]]] |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub diag_warning { # [[[ |
58
|
0
|
|
|
0
|
0
|
0
|
shift; |
59
|
0
|
|
|
|
|
0
|
Text::Frundis::Processing::diag_error(@_); |
60
|
|
|
|
|
|
|
} # ]]] |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub diag_error { # [[[ |
63
|
2
|
|
|
2
|
0
|
2
|
shift; |
64
|
2
|
|
|
|
|
5
|
Text::Frundis::Processing::diag_error(@_); |
65
|
|
|
|
|
|
|
} # ]]] |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub diag_fatal { # [[[ |
68
|
0
|
|
|
0
|
0
|
0
|
shift; |
69
|
0
|
|
|
|
|
0
|
Text::Frundis::Processing::diag_fatal(@_); |
70
|
|
|
|
|
|
|
} # ]]] |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub escape { # [[[ |
73
|
2
|
|
|
2
|
0
|
2
|
shift; |
74
|
2
|
|
|
|
|
4
|
Text::Frundis::Processing::escape(@_); |
75
|
|
|
|
|
|
|
} # ]]] |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub escape_text { # [[[ |
78
|
18
|
|
|
18
|
0
|
15
|
shift; |
79
|
18
|
|
|
|
|
34
|
Text::Frundis::Processing::escape_text(@_); |
80
|
|
|
|
|
|
|
} # ]]] |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub file { # [[[ |
83
|
2
|
|
|
2
|
0
|
2
|
my $self = shift; |
84
|
2
|
|
|
|
|
4
|
return ${ $self->{file} }; |
|
2
|
|
|
|
|
20
|
|
85
|
|
|
|
|
|
|
} # ]]] |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub flag { # [[[ |
88
|
2
|
|
|
2
|
0
|
2
|
my $self = shift; |
89
|
2
|
|
|
|
|
3
|
my @arg = @_; |
90
|
2
|
50
|
|
|
|
6
|
if (@arg == 1) { |
|
|
0
|
|
|
|
|
|
91
|
2
|
|
|
|
|
24
|
return $self->{flags}{ $arg[0] }; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
elsif (@arg == 2) { |
94
|
0
|
0
|
|
|
|
0
|
return unless $self->process; |
95
|
0
|
0
|
0
|
|
|
0
|
unless ($self->{allowed_flags}{ $_[0] } |
96
|
|
|
|
|
|
|
and $self->{allowed_flags}{ $_[0] } !~ /^_/) |
97
|
|
|
|
|
|
|
{ |
98
|
0
|
|
|
|
|
0
|
$self->{allowed_flags}{ $_[0] } = 1; |
99
|
|
|
|
|
|
|
} |
100
|
0
|
|
|
|
|
0
|
$self->{flags}{ $_[0] } = $_[1]; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
else { |
103
|
0
|
|
|
|
|
0
|
$self->diag_error("perl:method flag has one or two arguments"); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} # ]]] |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub format { # [[[ |
108
|
5
|
|
|
5
|
0
|
5
|
my $self = shift; |
109
|
5
|
|
|
|
|
55
|
return $self->{format}; |
110
|
|
|
|
|
|
|
} # ]]] |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub get_close_delim { # [[[ |
113
|
18
|
|
|
18
|
0
|
13
|
shift; |
114
|
18
|
|
|
|
|
38
|
Text::Frundis::Processing::get_close_delim(); |
115
|
|
|
|
|
|
|
} # ]]] |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub ivars { # [[[ |
118
|
18
|
|
|
18
|
0
|
18
|
my $self = shift; |
119
|
18
|
|
|
|
|
115
|
return $self->{ivars}; |
120
|
|
|
|
|
|
|
} # ]]] |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub lnum { # [[[ |
123
|
2
|
|
|
2
|
0
|
3
|
my $self = shift; |
124
|
2
|
|
|
|
|
20
|
return $self->{state}{lnum}; |
125
|
|
|
|
|
|
|
} # ]]] |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub loX_entry_infos { # [[[ |
128
|
8
|
|
|
8
|
0
|
10
|
my $self = shift; |
129
|
8
|
50
|
|
|
|
10
|
return if $self->process; |
130
|
8
|
|
|
|
|
16
|
Text::Frundis::Processing::loX_entry_infos(@_); |
131
|
|
|
|
|
|
|
} # ]]] |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub macro { # [[[ |
134
|
2
|
|
|
2
|
0
|
2
|
my $self = shift; |
135
|
2
|
|
|
|
|
21
|
return $self->{state}{macro}; |
136
|
|
|
|
|
|
|
} # ]]] |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub new_id { # [[[ |
139
|
8
|
|
|
8
|
0
|
6
|
my $self = shift; |
140
|
8
|
|
|
|
|
10
|
my $id = shift; |
141
|
8
|
|
|
|
|
12
|
$id = Text::Frundis::Processing::escape_text($id); |
142
|
8
|
|
|
|
|
19
|
$self->{ID}{$id} = Text::Frundis::Processing::xhtml_gen_href("", $id); |
143
|
|
|
|
|
|
|
} # ]]] |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub param { # [[[ |
146
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
147
|
2
|
50
|
|
|
|
7
|
if (@_ == 1) { |
|
|
50
|
|
|
|
|
|
148
|
0
|
|
|
|
|
0
|
return $self->{params}{ $_[0] }; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
elsif (@_ == 2) { |
151
|
2
|
50
|
|
|
|
4
|
return unless $self->process; |
152
|
2
|
50
|
33
|
|
|
7
|
unless ($self->{allowed_params}{ $_[0] } |
153
|
|
|
|
|
|
|
and $self->{allowed_params}{ $_[0] } !~ /^_/) |
154
|
|
|
|
|
|
|
{ |
155
|
2
|
|
|
|
|
5
|
$self->{allowed_params}{ $_[0] } = 1; |
156
|
|
|
|
|
|
|
} |
157
|
2
|
|
|
|
|
25
|
$self->{params}{ $_[0] } = $_[1]; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
else { |
160
|
0
|
|
|
|
|
0
|
diag_error("perl:method param has one or two arguments"); |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
} # ]]] |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub parse_options { # [[[ |
165
|
2
|
|
|
2
|
0
|
3
|
shift; |
166
|
2
|
|
|
|
|
4
|
Text::Frundis::Processing::parse_options(@_); |
167
|
|
|
|
|
|
|
} # ]]] |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub phrasing_macro_begin { # [[[ |
170
|
28
|
|
|
28
|
0
|
29
|
shift; |
171
|
28
|
|
|
|
|
46
|
Text::Frundis::Processing::phrasing_macro_begin(@_); |
172
|
|
|
|
|
|
|
} # ]]] |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub phrasing_macro_end { # [[[ |
175
|
2
|
|
|
2
|
0
|
3
|
shift; |
176
|
2
|
|
|
|
|
4
|
Text::Frundis::Processing::phrasing_macro_end(@_); |
177
|
|
|
|
|
|
|
} # ]]] |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub process { # [[[ |
180
|
94
|
|
|
94
|
0
|
86
|
my $self = shift; |
181
|
94
|
|
|
|
|
66
|
return ${ $self->{process} }; |
|
94
|
|
|
|
|
874
|
|
182
|
|
|
|
|
|
|
} # ]]] |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub text { # [[[ |
185
|
6
|
|
|
6
|
0
|
9
|
my $self = shift; |
186
|
6
|
|
|
|
|
8
|
my @arg = @_; |
187
|
6
|
100
|
|
|
|
11
|
if (@arg == 0) { |
|
|
50
|
|
|
|
|
|
188
|
4
|
|
|
|
|
41
|
return $self->{state}{text}; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
elsif (@arg == 1) { |
191
|
2
|
|
|
|
|
7
|
$self->{state}{text} = $arg[0]; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
else { |
194
|
0
|
|
|
|
|
0
|
diag_error("perl:method text has one or two arguments"); |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
} # ]]] |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub vars { # [[[ |
199
|
42
|
|
|
42
|
0
|
379
|
return shift->{vars}; |
200
|
|
|
|
|
|
|
} # ]]] |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub xhtml_gen_href { # [[[ |
203
|
0
|
|
|
0
|
0
|
0
|
shift; |
204
|
0
|
|
|
|
|
0
|
Text::Frundis::Processing::xhtml_gen_href(@_); |
205
|
|
|
|
|
|
|
} # ]]] |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub xhtml_loX { # [[[ |
208
|
4
|
|
|
4
|
0
|
15
|
my $self = shift; |
209
|
4
|
50
|
|
|
|
8
|
return unless $self->process; |
210
|
4
|
|
|
|
|
13
|
Text::Frundis::Processing::xhtml_loX(@_); |
211
|
|
|
|
|
|
|
} # ]]] |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
1; |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
# vim:foldmarker=[[[,]]]:foldmethod=marker:sw=4:sts=4:expandtab |