| 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
|
|
15
|
use utf8; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
21
|
|
|
22
|
3
|
|
|
3
|
|
91
|
use v5.12; |
|
|
3
|
|
|
|
|
10
|
|
|
23
|
3
|
|
|
3
|
|
18
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
61
|
|
|
24
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
84
|
|
|
25
|
3
|
|
|
3
|
|
18
|
use open qw(:std :utf8); |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
24
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
3
|
|
|
3
|
|
377
|
use Exporter 'import'; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
113
|
|
|
28
|
3
|
|
|
3
|
|
14
|
use Text::Frundis::Processing; |
|
|
3
|
|
|
|
|
9
|
|
|
|
3
|
|
|
|
|
4290
|
|
|
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
|
146
|
my $class = shift; |
|
35
|
60
|
|
|
|
|
92
|
my $self = shift; |
|
36
|
60
|
|
|
|
|
245
|
bless $self, $class; |
|
37
|
|
|
|
|
|
|
} # ]]] |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# methods, in alphabetic order |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub args { # [[[ |
|
42
|
4
|
|
|
4
|
0
|
7
|
shift; |
|
43
|
4
|
|
|
|
|
28
|
return \@Arg; |
|
44
|
|
|
|
|
|
|
} # ]]] |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub call { # [[[ |
|
47
|
12
|
|
|
12
|
0
|
27
|
shift; |
|
48
|
12
|
|
|
|
|
43
|
Text::Frundis::Processing::call(@_); |
|
49
|
|
|
|
|
|
|
} # ]]] |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _call_perl_macro { # [[[ |
|
52
|
86
|
|
|
86
|
|
122
|
my $self = shift; |
|
53
|
86
|
|
|
|
|
172
|
my $macro = shift; |
|
54
|
86
|
|
|
|
|
1859
|
$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
|
4
|
shift; |
|
64
|
2
|
|
|
|
|
10
|
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
|
5
|
shift; |
|
74
|
2
|
|
|
|
|
7
|
Text::Frundis::Processing::escape(@_); |
|
75
|
|
|
|
|
|
|
} # ]]] |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub escape_text { # [[[ |
|
78
|
18
|
|
|
18
|
0
|
26
|
shift; |
|
79
|
18
|
|
|
|
|
88
|
Text::Frundis::Processing::escape_text(@_); |
|
80
|
|
|
|
|
|
|
} # ]]] |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub file { # [[[ |
|
83
|
2
|
|
|
2
|
0
|
5
|
my $self = shift; |
|
84
|
2
|
|
|
|
|
5
|
return ${ $self->{file} }; |
|
|
2
|
|
|
|
|
36
|
|
|
85
|
|
|
|
|
|
|
} # ]]] |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub flag { # [[[ |
|
88
|
2
|
|
|
2
|
0
|
5
|
my $self = shift; |
|
89
|
2
|
|
|
|
|
5
|
my @arg = @_; |
|
90
|
2
|
50
|
|
|
|
8
|
if (@arg == 1) { |
|
|
|
0
|
|
|
|
|
|
|
91
|
2
|
|
|
|
|
46
|
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
|
10
|
my $self = shift; |
|
109
|
5
|
|
|
|
|
89
|
return $self->{format}; |
|
110
|
|
|
|
|
|
|
} # ]]] |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub get_close_delim { # [[[ |
|
113
|
18
|
|
|
18
|
0
|
28
|
shift; |
|
114
|
18
|
|
|
|
|
49
|
Text::Frundis::Processing::get_close_delim(); |
|
115
|
|
|
|
|
|
|
} # ]]] |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub ivars { # [[[ |
|
118
|
18
|
|
|
18
|
0
|
29
|
my $self = shift; |
|
119
|
18
|
|
|
|
|
214
|
return $self->{ivars}; |
|
120
|
|
|
|
|
|
|
} # ]]] |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub lnum { # [[[ |
|
123
|
2
|
|
|
2
|
0
|
5
|
my $self = shift; |
|
124
|
2
|
|
|
|
|
36
|
return $self->{state}{lnum}; |
|
125
|
|
|
|
|
|
|
} # ]]] |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub loX_entry_infos { # [[[ |
|
128
|
8
|
|
|
8
|
0
|
13
|
my $self = shift; |
|
129
|
8
|
50
|
|
|
|
26
|
return if $self->process; |
|
130
|
8
|
|
|
|
|
29
|
Text::Frundis::Processing::loX_entry_infos(@_); |
|
131
|
|
|
|
|
|
|
} # ]]] |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub macro { # [[[ |
|
134
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
|
135
|
2
|
|
|
|
|
35
|
return $self->{state}{macro}; |
|
136
|
|
|
|
|
|
|
} # ]]] |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub new_id { # [[[ |
|
139
|
8
|
|
|
8
|
0
|
12
|
my $self = shift; |
|
140
|
8
|
|
|
|
|
14
|
my $id = shift; |
|
141
|
8
|
|
|
|
|
18
|
$id = Text::Frundis::Processing::escape_text($id); |
|
142
|
8
|
|
|
|
|
23
|
$self->{ID}{$id} = Text::Frundis::Processing::xhtml_gen_href("", $id); |
|
143
|
|
|
|
|
|
|
} # ]]] |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub param { # [[[ |
|
146
|
2
|
|
|
2
|
0
|
4
|
my $self = shift; |
|
147
|
2
|
50
|
|
|
|
11
|
if (@_ == 1) { |
|
|
|
50
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
0
|
return $self->{params}{ $_[0] }; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
elsif (@_ == 2) { |
|
151
|
2
|
50
|
|
|
|
7
|
return unless $self->process; |
|
152
|
2
|
50
|
33
|
|
|
20
|
unless ($self->{allowed_params}{ $_[0] } |
|
153
|
|
|
|
|
|
|
and $self->{allowed_params}{ $_[0] } !~ /^_/) |
|
154
|
|
|
|
|
|
|
{ |
|
155
|
2
|
|
|
|
|
7
|
$self->{allowed_params}{ $_[0] } = 1; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
2
|
|
|
|
|
42
|
$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
|
4
|
shift; |
|
166
|
2
|
|
|
|
|
7
|
Text::Frundis::Processing::parse_options(@_); |
|
167
|
|
|
|
|
|
|
} # ]]] |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub phrasing_macro_begin { # [[[ |
|
170
|
28
|
|
|
28
|
0
|
40
|
shift; |
|
171
|
28
|
|
|
|
|
89
|
Text::Frundis::Processing::phrasing_macro_begin(@_); |
|
172
|
|
|
|
|
|
|
} # ]]] |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub phrasing_macro_end { # [[[ |
|
175
|
2
|
|
|
2
|
0
|
4
|
shift; |
|
176
|
2
|
|
|
|
|
10
|
Text::Frundis::Processing::phrasing_macro_end(@_); |
|
177
|
|
|
|
|
|
|
} # ]]] |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub process { # [[[ |
|
180
|
94
|
|
|
94
|
0
|
135
|
my $self = shift; |
|
181
|
94
|
|
|
|
|
102
|
return ${ $self->{process} }; |
|
|
94
|
|
|
|
|
1607
|
|
|
182
|
|
|
|
|
|
|
} # ]]] |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub text { # [[[ |
|
185
|
6
|
|
|
6
|
0
|
18
|
my $self = shift; |
|
186
|
6
|
|
|
|
|
13
|
my @arg = @_; |
|
187
|
6
|
100
|
|
|
|
17
|
if (@arg == 0) { |
|
|
|
50
|
|
|
|
|
|
|
188
|
4
|
|
|
|
|
66
|
return $self->{state}{text}; |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
elsif (@arg == 1) { |
|
191
|
2
|
|
|
|
|
10
|
$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
|
703
|
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
|
14
|
my $self = shift; |
|
209
|
4
|
50
|
|
|
|
10
|
return unless $self->process; |
|
210
|
4
|
|
|
|
|
14
|
Text::Frundis::Processing::xhtml_loX(@_); |
|
211
|
|
|
|
|
|
|
} # ]]] |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
1; |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
# vim:foldmarker=[[[,]]]:foldmethod=marker:sw=4:sts=4:expandtab |