| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::Amuse::Compile::MuseHeader; |
|
2
|
|
|
|
|
|
|
|
|
3
|
58
|
|
|
58
|
|
395
|
use Moo; |
|
|
58
|
|
|
|
|
132
|
|
|
|
58
|
|
|
|
|
400
|
|
|
4
|
58
|
|
|
58
|
|
17015
|
use Types::Standard qw/HashRef Bool Str ArrayRef/; |
|
|
58
|
|
|
|
|
147
|
|
|
|
58
|
|
|
|
|
441
|
|
|
5
|
58
|
|
|
58
|
|
46554
|
use Text::Amuse::Functions qw/muse_format_line/; |
|
|
58
|
|
|
|
|
131
|
|
|
|
58
|
|
|
|
|
3501
|
|
|
6
|
58
|
|
|
58
|
|
383
|
use Text::Amuse::InlineElement; |
|
|
58
|
|
|
|
|
147
|
|
|
|
58
|
|
|
|
|
104659
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Text::Amuse::Compile::MuseHeader - Module to parse muse metadata |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
This class is still a work in progress. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 METHODS |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head2 new(\%header) |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Constructor. It accepts only one mandatory argument with the output of |
|
21
|
|
|
|
|
|
|
muse_fast_scan_header (an hashref). |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 wants_slides |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Return true if slides are needed. False if C<#slides> is not present |
|
26
|
|
|
|
|
|
|
or "no" or "false". |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 header |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
The cleaned and lowercased header. Directives with underscores are |
|
31
|
|
|
|
|
|
|
ignored. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 title |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Verbatim header field |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 subtitle |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Verbatim header field |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 listtitle |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Verbatim header field |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 listing_title |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Return listtitle if set, title otherwise. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 author |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Verbatim header field |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 language |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Defaults to en if not present. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 topics |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
An arrayref with topics from C, C and C |
|
60
|
|
|
|
|
|
|
fields. The C field is meant to be reserved from fixed category |
|
61
|
|
|
|
|
|
|
list, so it splits at space too, while the others split at semicolon |
|
62
|
|
|
|
|
|
|
(if present) or at comma. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 authors |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
An arrayref with the authors from C and C |
|
67
|
|
|
|
|
|
|
fields. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Fields split at semicolon if present, otherwise at comma. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 topics_as_html_list |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Same as C, but returns a plain list of HTML formatted topics. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 authors_as_html_list |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Same as C, but returns a plain list of HTML formatted authors. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 tex_metadata |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Return an hashref with the following keys: C C |
|
82
|
|
|
|
|
|
|
C C with the values LaTeX escaped, mapping to the |
|
83
|
|
|
|
|
|
|
relevant headers values for setting PDF metadata. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 INTERNALS |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 BUILDARGS |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Moo-ifies the constructor. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub BUILDARGS { |
|
94
|
356
|
|
|
356
|
1
|
450237
|
my ($class, $hash) = @_; |
|
95
|
356
|
50
|
|
|
|
1299
|
if ($hash) { |
|
96
|
356
|
50
|
|
|
|
1742
|
die "Argument must be an hashref" unless ref($hash) eq 'HASH'; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
else { |
|
99
|
0
|
|
|
|
|
0
|
die "Missing argument"; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
356
|
|
|
|
|
2038
|
my $directives = { %$hash }; |
|
102
|
356
|
|
|
|
|
963
|
my %lowered; |
|
103
|
|
|
|
|
|
|
DIRECTIVE: |
|
104
|
356
|
|
|
|
|
1555
|
foreach my $k (keys %$directives) { |
|
105
|
996
|
50
|
|
|
|
2727
|
if ($k =~ m/_/) { |
|
106
|
0
|
|
|
|
|
0
|
warn "Ignoring $k directive with underscore\n"; |
|
107
|
0
|
|
|
|
|
0
|
next DIRECTIVE; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
996
|
|
|
|
|
2335
|
my $lck = lc($k); |
|
110
|
996
|
50
|
|
|
|
2525
|
if (exists $lowered{$lck}) { |
|
111
|
0
|
|
|
|
|
0
|
warn "Overwriting $lck, directives are case insensitive!\n"; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
996
|
|
|
|
|
2511
|
$lowered{$lck} = $directives->{$k}; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
356
|
|
|
|
|
2527
|
my %args = (header => { %lowered }); |
|
116
|
356
|
|
|
|
|
1643
|
foreach my $f (qw/title listtitle subtitle author/) { |
|
117
|
1424
|
100
|
66
|
|
|
7307
|
if (exists $lowered{$f} and |
|
|
|
|
100
|
|
|
|
|
|
118
|
|
|
|
|
|
|
defined $lowered{$f} and |
|
119
|
|
|
|
|
|
|
$lowered{$f} =~ m/\w/) { |
|
120
|
528
|
|
|
|
|
1668
|
$args{$f} = $lowered{$f}; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
else { |
|
123
|
896
|
|
|
|
|
1986
|
$args{$f} = ''; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
} |
|
126
|
356
|
|
|
|
|
6734
|
return \%args; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
has title => (is => 'ro', isa => Str, required => 1); |
|
130
|
|
|
|
|
|
|
has subtitle => (is => 'ro', isa => Str, required => 1); |
|
131
|
|
|
|
|
|
|
has listtitle => (is => 'ro', isa => Str, required => 1); |
|
132
|
|
|
|
|
|
|
has author => (is => 'ro', isa => Str, required => 1); |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
has header => (is => 'ro', isa => HashRef[Str]); |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
has language => (is => 'lazy', isa => Str); |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub _build_language { |
|
139
|
31
|
|
|
31
|
|
9385
|
my $self = shift; |
|
140
|
31
|
|
|
|
|
77
|
my $lang = 'en'; |
|
141
|
|
|
|
|
|
|
# language treatment |
|
142
|
31
|
100
|
|
|
|
151
|
if (my $lang_orig = $self->header->{lang}) { |
|
143
|
22
|
50
|
|
|
|
113
|
if ($lang_orig =~ m/([a-z]{2,3})/) { |
|
144
|
22
|
|
|
|
|
61
|
$lang = $1; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
else { |
|
147
|
0
|
|
|
|
|
0
|
warn qq[Garbage $lang_orig found in #lang, using "en" instead\n]; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
else { |
|
151
|
9
|
|
|
|
|
627
|
warn "No language found, assuming english\n"; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
31
|
|
|
|
|
537
|
return $lang; |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
has wants_slides => (is => 'lazy', isa => Bool); |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub _build_wants_slides { |
|
159
|
41
|
|
|
41
|
|
4824
|
my $self = shift; |
|
160
|
41
|
|
|
|
|
77
|
my $bool = 0; |
|
161
|
41
|
100
|
|
|
|
164
|
if (my $slides = $self->header->{slides}) { |
|
162
|
31
|
100
|
66
|
|
|
279
|
if (!$slides or $slides =~ /^\s*(no|false)\s*$/si) { |
|
163
|
13
|
|
|
|
|
28
|
$bool = 0; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
else { |
|
166
|
18
|
|
|
|
|
39
|
$bool = 1; |
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
} |
|
169
|
41
|
|
|
|
|
547
|
return $bool; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
has is_deleted => (is => 'lazy', isa => Bool); |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub _build_is_deleted { |
|
175
|
303
|
|
|
303
|
|
74922
|
return !!shift->header->{deleted}; |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
has cover => (is => 'lazy', isa => Str); |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub _build_cover { |
|
181
|
291
|
|
|
291
|
|
12974
|
my $self = shift; |
|
182
|
291
|
100
|
|
|
|
1516
|
if (my $cover = $self->header->{cover}) { |
|
183
|
59
|
100
|
|
|
|
539
|
if ($cover =~ m/\A |
|
184
|
|
|
|
|
|
|
( |
|
185
|
|
|
|
|
|
|
[a-zA-Z0-9] |
|
186
|
|
|
|
|
|
|
[a-zA-Z0-9-]* |
|
187
|
|
|
|
|
|
|
[a-zA-Z0-9] |
|
188
|
|
|
|
|
|
|
\.(jpe?g|png) |
|
189
|
|
|
|
|
|
|
)\z |
|
190
|
|
|
|
|
|
|
/x) { |
|
191
|
48
|
100
|
|
|
|
696
|
if (-f $cover) { |
|
192
|
47
|
|
|
|
|
1002
|
return $cover; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
} |
|
196
|
244
|
|
|
|
|
3478
|
return ''; |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
has coverwidth => (is => 'lazy', isa => Str); |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub _build_coverwidth { |
|
203
|
|
|
|
|
|
|
# compare with TemplateOptions |
|
204
|
49
|
|
|
49
|
|
4393
|
my $self = shift; |
|
205
|
49
|
100
|
|
|
|
732
|
if ($self->cover) { |
|
206
|
47
|
100
|
|
|
|
550
|
if (my $width = $self->header->{coverwidth}) { |
|
207
|
6
|
100
|
|
|
|
44
|
if ($width =~ m/\A[01](\.[0-9][0-9]?)?\z/) { |
|
208
|
5
|
|
|
|
|
76
|
return $width; |
|
209
|
|
|
|
|
|
|
} |
|
210
|
|
|
|
|
|
|
else { |
|
211
|
1
|
|
|
|
|
32
|
warn "Invalid measure passed for coverwidth, should be 0.01 => 1.00\n"; |
|
212
|
|
|
|
|
|
|
} |
|
213
|
|
|
|
|
|
|
} |
|
214
|
42
|
|
|
|
|
655
|
return 1; |
|
215
|
|
|
|
|
|
|
} |
|
216
|
2
|
|
|
|
|
39
|
return 0; |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
has nocoverpage => (is => 'lazy', isa => Bool); |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub _build_nocoverpage { |
|
222
|
290
|
|
|
290
|
|
10075
|
my $self = shift; |
|
223
|
290
|
|
|
|
|
4499
|
return !!$self->header->{nocoverpage}; |
|
224
|
|
|
|
|
|
|
} |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
has notoc => (is => 'lazy', isa => Bool); |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub _build_notoc { |
|
229
|
288
|
|
|
288
|
|
9376
|
my $self = shift; |
|
230
|
288
|
|
|
|
|
4383
|
return !!$self->header->{notoc}; |
|
231
|
|
|
|
|
|
|
} |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
has nofinalpage => (is => 'lazy', isa => Bool); |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub _build_nofinalpage { |
|
236
|
288
|
|
|
288
|
|
9207
|
my $self = shift; |
|
237
|
288
|
|
|
|
|
4464
|
return !!$self->header->{nofinalpage}; |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
has impressum => (is => 'lazy', isa => Bool); |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
sub _build_impressum { |
|
243
|
288
|
|
|
288
|
|
9705
|
my $self = shift; |
|
244
|
288
|
|
|
|
|
4380
|
return !!$self->header->{impressum}; |
|
245
|
|
|
|
|
|
|
} |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
has continuefootnotes => (is => 'lazy', isa => Bool ); |
|
248
|
|
|
|
|
|
|
has centerchapter => (is => 'lazy', isa => Bool ); |
|
249
|
|
|
|
|
|
|
has centersection => (is => 'lazy', isa => Bool ); |
|
250
|
288
|
|
|
288
|
|
9982
|
sub _build_continuefootnotes { shift->_look_at_header('continuefootnotes') } |
|
251
|
294
|
|
|
294
|
|
9807
|
sub _build_centerchapter { shift->_look_at_header('centerchapter') } |
|
252
|
294
|
|
|
294
|
|
10451
|
sub _build_centersection { shift->_look_at_header('centersection') } |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
sub _look_at_header { |
|
255
|
876
|
|
|
876
|
|
2285
|
my ($self, $key) = @_; |
|
256
|
876
|
|
|
|
|
12991
|
return !!$self->header->{$key}; |
|
257
|
|
|
|
|
|
|
} |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
has topics => (is => 'lazy', isa => ArrayRef); |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
sub _build_topics { |
|
262
|
259
|
|
|
259
|
|
4123
|
my $self = shift; |
|
263
|
259
|
|
|
|
|
478
|
my @topics; |
|
264
|
259
|
|
|
|
|
776
|
foreach my $field (qw/cat sorttopics topics/) { |
|
265
|
777
|
|
|
|
|
1534
|
push @topics, $self->_parse_topic_or_author($field); |
|
266
|
|
|
|
|
|
|
} |
|
267
|
259
|
|
|
|
|
4250
|
return \@topics; |
|
268
|
|
|
|
|
|
|
} |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
has authors => (is => 'lazy', isa => ArrayRef); |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
sub _build_authors { |
|
273
|
259
|
|
|
259
|
|
5216
|
my $self = shift; |
|
274
|
259
|
|
|
|
|
488
|
my @authors; |
|
275
|
259
|
|
|
|
|
805
|
foreach my $field (qw/authors sortauthors/) { |
|
276
|
518
|
|
|
|
|
1577
|
push @authors, $self->_parse_topic_or_author($field); |
|
277
|
|
|
|
|
|
|
} |
|
278
|
259
|
|
|
|
|
4092
|
return \@authors; |
|
279
|
|
|
|
|
|
|
} |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
sub authors_as_html_list { |
|
282
|
71
|
|
|
71
|
1
|
1108
|
my $self = shift; |
|
283
|
71
|
|
|
|
|
1538
|
return $self->_html_strings($self->authors); |
|
284
|
|
|
|
|
|
|
} |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
sub topics_as_html_list { |
|
287
|
71
|
|
|
71
|
1
|
1301
|
my $self = shift; |
|
288
|
71
|
|
|
|
|
1414
|
return $self->_html_strings($self->topics); |
|
289
|
|
|
|
|
|
|
} |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
sub _html_strings { |
|
292
|
142
|
|
|
142
|
|
4365
|
my ($self, $list) = @_; |
|
293
|
142
|
|
|
|
|
229
|
my @out; |
|
294
|
142
|
|
|
|
|
338
|
foreach my $el (@$list) { |
|
295
|
26
|
|
|
|
|
8230
|
push @out, muse_format_line(html => $el); |
|
296
|
|
|
|
|
|
|
} |
|
297
|
142
|
|
|
|
|
7098
|
return @out; |
|
298
|
|
|
|
|
|
|
} |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
sub listing_title { |
|
301
|
255
|
|
|
255
|
1
|
538
|
my $self = shift; |
|
302
|
255
|
100
|
|
|
|
1317
|
if (length($self->listtitle)) { |
|
303
|
1
|
|
|
|
|
5
|
return $self->listtitle; |
|
304
|
|
|
|
|
|
|
} |
|
305
|
|
|
|
|
|
|
else { |
|
306
|
254
|
|
|
|
|
1201
|
return $self->title; |
|
307
|
|
|
|
|
|
|
} |
|
308
|
|
|
|
|
|
|
} |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
sub tex_metadata { |
|
311
|
254
|
|
|
254
|
1
|
5975
|
my $self = shift; |
|
312
|
|
|
|
|
|
|
my %out = ( |
|
313
|
|
|
|
|
|
|
title => $self->listing_title, |
|
314
|
254
|
|
|
|
|
4318
|
author => (scalar(@{$self->authors}) ? join('; ', @{$self->authors}) : $self->author), |
|
|
2
|
|
|
|
|
41
|
|
|
315
|
|
|
|
|
|
|
subject => $self->subtitle, |
|
316
|
254
|
100
|
|
|
|
1092
|
keywords => (scalar(@{$self->topics}) ? join('; ', @{$self->topics}) : ''), |
|
|
254
|
100
|
|
|
|
10602
|
|
|
|
8
|
|
|
|
|
295
|
|
|
317
|
|
|
|
|
|
|
); |
|
318
|
254
|
|
|
|
|
7539
|
foreach my $k (keys %out) { |
|
319
|
|
|
|
|
|
|
# just escape |
|
320
|
1016
|
|
|
|
|
58748
|
$out{$k} = Text::Amuse::InlineElement->new(string => $out{$k}, |
|
321
|
|
|
|
|
|
|
type => 'text', |
|
322
|
|
|
|
|
|
|
fmt => 'ltx')->stringify; |
|
323
|
|
|
|
|
|
|
} |
|
324
|
254
|
|
|
|
|
22061
|
return \%out; |
|
325
|
|
|
|
|
|
|
} |
|
326
|
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
sub _parse_topic_or_author { |
|
328
|
1295
|
|
|
1295
|
|
2333
|
my ($self, $field) = @_; |
|
329
|
1295
|
|
|
|
|
2779
|
my $header = $self->header; |
|
330
|
1295
|
|
|
|
|
3998
|
my %fields = ( |
|
331
|
|
|
|
|
|
|
cat => 1, |
|
332
|
|
|
|
|
|
|
sorttopics => 1, |
|
333
|
|
|
|
|
|
|
sortauthors => 1, |
|
334
|
|
|
|
|
|
|
topics => 1, |
|
335
|
|
|
|
|
|
|
authors => 1, |
|
336
|
|
|
|
|
|
|
); |
|
337
|
|
|
|
|
|
|
die "Called _parse_topic_or_author for unknown field $field" |
|
338
|
1295
|
50
|
|
|
|
2761
|
unless $fields{$field}; |
|
339
|
1295
|
|
|
|
|
1692
|
my @out; |
|
340
|
1295
|
100
|
|
|
|
2692
|
if (exists $header->{$field}) { |
|
341
|
22
|
|
|
|
|
63
|
my $string = $header->{$field}; |
|
342
|
22
|
50
|
33
|
|
|
114
|
if (defined $string and length $string) { |
|
343
|
22
|
|
|
|
|
87
|
my $separator = qr{\s*\,\s*}; |
|
344
|
22
|
100
|
|
|
|
102
|
if ($field eq 'cat') { |
|
|
|
100
|
|
|
|
|
|
|
345
|
4
|
|
|
|
|
17
|
$separator = qr{[\s;,]+}; |
|
346
|
|
|
|
|
|
|
} |
|
347
|
|
|
|
|
|
|
elsif ($string =~ m/\;/) { |
|
348
|
15
|
|
|
|
|
63
|
$separator = qr{\s*\;\s*}; |
|
349
|
|
|
|
|
|
|
} |
|
350
|
22
|
|
|
|
|
271
|
@out = grep { /\w/ } split(/$separator/, $string); |
|
|
61
|
|
|
|
|
224
|
|
|
351
|
|
|
|
|
|
|
} |
|
352
|
|
|
|
|
|
|
} |
|
353
|
1295
|
|
|
|
|
3228
|
return @out; |
|
354
|
|
|
|
|
|
|
} |
|
355
|
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
1; |