| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::Amuse::Compile::MuseHeader; |
|
2
|
|
|
|
|
|
|
|
|
3
|
59
|
|
|
59
|
|
468
|
use Moo; |
|
|
59
|
|
|
|
|
137
|
|
|
|
59
|
|
|
|
|
469
|
|
|
4
|
59
|
|
|
59
|
|
21001
|
use Types::Standard qw/HashRef Bool Str ArrayRef/; |
|
|
59
|
|
|
|
|
165
|
|
|
|
59
|
|
|
|
|
542
|
|
|
5
|
59
|
|
|
59
|
|
56363
|
use Text::Amuse::Functions qw/muse_format_line/; |
|
|
59
|
|
|
|
|
145
|
|
|
|
59
|
|
|
|
|
4188
|
|
|
6
|
59
|
|
|
59
|
|
442
|
use Text::Amuse::InlineElement; |
|
|
59
|
|
|
|
|
168
|
|
|
|
59
|
|
|
|
|
118875
|
|
|
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
|
360
|
|
|
360
|
1
|
517620
|
my ($class, $hash) = @_; |
|
95
|
360
|
50
|
|
|
|
1424
|
if ($hash) { |
|
96
|
360
|
50
|
|
|
|
1947
|
die "Argument must be an hashref" unless ref($hash) eq 'HASH'; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
else { |
|
99
|
0
|
|
|
|
|
0
|
die "Missing argument"; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
360
|
|
|
|
|
2373
|
my $directives = { %$hash }; |
|
102
|
360
|
|
|
|
|
1117
|
my %lowered; |
|
103
|
|
|
|
|
|
|
DIRECTIVE: |
|
104
|
360
|
|
|
|
|
1784
|
foreach my $k (keys %$directives) { |
|
105
|
1004
|
50
|
|
|
|
3232
|
if ($k =~ m/_/) { |
|
106
|
0
|
|
|
|
|
0
|
warn "Ignoring $k directive with underscore\n"; |
|
107
|
0
|
|
|
|
|
0
|
next DIRECTIVE; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
1004
|
|
|
|
|
2685
|
my $lck = lc($k); |
|
110
|
1004
|
50
|
|
|
|
2834
|
if (exists $lowered{$lck}) { |
|
111
|
0
|
|
|
|
|
0
|
warn "Overwriting $lck, directives are case insensitive!\n"; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
1004
|
|
|
|
|
2957
|
$lowered{$lck} = $directives->{$k}; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
360
|
|
|
|
|
2754
|
my %args = (header => { %lowered }); |
|
116
|
360
|
|
|
|
|
1366
|
foreach my $f (qw/title listtitle subtitle author/) { |
|
117
|
1440
|
100
|
66
|
|
|
7922
|
if (exists $lowered{$f} and |
|
|
|
|
100
|
|
|
|
|
|
118
|
|
|
|
|
|
|
defined $lowered{$f} and |
|
119
|
|
|
|
|
|
|
$lowered{$f} =~ m/\w/) { |
|
120
|
532
|
|
|
|
|
1827
|
$args{$f} = $lowered{$f}; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
else { |
|
123
|
908
|
|
|
|
|
2321
|
$args{$f} = ''; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
} |
|
126
|
360
|
|
|
|
|
8216
|
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
|
|
10248
|
my $self = shift; |
|
140
|
31
|
|
|
|
|
78
|
my $lang = 'en'; |
|
141
|
|
|
|
|
|
|
# language treatment |
|
142
|
31
|
100
|
|
|
|
168
|
if (my $lang_orig = $self->header->{lang}) { |
|
143
|
22
|
50
|
|
|
|
106
|
if ($lang_orig =~ m/([a-z]{2,3})/) { |
|
144
|
22
|
|
|
|
|
68
|
$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
|
|
|
|
|
791
|
warn "No language found, assuming english\n"; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
31
|
|
|
|
|
628
|
return $lang; |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
has wants_slides => (is => 'lazy', isa => Bool); |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub _build_wants_slides { |
|
159
|
41
|
|
|
41
|
|
5697
|
my $self = shift; |
|
160
|
41
|
|
|
|
|
75
|
my $bool = 0; |
|
161
|
41
|
100
|
|
|
|
191
|
if (my $slides = $self->header->{slides}) { |
|
162
|
31
|
100
|
66
|
|
|
274
|
if (!$slides or $slides =~ /^\s*(no|false)\s*$/si) { |
|
163
|
13
|
|
|
|
|
28
|
$bool = 0; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
else { |
|
166
|
18
|
|
|
|
|
45
|
$bool = 1; |
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
} |
|
169
|
41
|
|
|
|
|
686
|
return $bool; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
has is_deleted => (is => 'lazy', isa => Bool); |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub _build_is_deleted { |
|
175
|
307
|
|
|
307
|
|
84153
|
return !!shift->header->{deleted}; |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
has cover => (is => 'lazy', isa => Str); |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub _build_cover { |
|
181
|
295
|
|
|
295
|
|
14224
|
my $self = shift; |
|
182
|
295
|
100
|
|
|
|
1666
|
if (my $cover = $self->header->{cover}) { |
|
183
|
59
|
100
|
|
|
|
525
|
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
|
|
|
|
743
|
if (-f $cover) { |
|
192
|
47
|
|
|
|
|
1152
|
return $cover; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
} |
|
196
|
248
|
|
|
|
|
4189
|
return ''; |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
has coverwidth => (is => 'lazy', isa => Str); |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub _build_coverwidth { |
|
203
|
|
|
|
|
|
|
# compare with TemplateOptions |
|
204
|
49
|
|
|
49
|
|
4954
|
my $self = shift; |
|
205
|
49
|
100
|
|
|
|
848
|
if ($self->cover) { |
|
206
|
47
|
100
|
|
|
|
636
|
if (my $width = $self->header->{coverwidth}) { |
|
207
|
6
|
100
|
|
|
|
47
|
if ($width =~ m/\A[01](\.[0-9][0-9]?)?\z/) { |
|
208
|
5
|
|
|
|
|
84
|
return $width; |
|
209
|
|
|
|
|
|
|
} |
|
210
|
|
|
|
|
|
|
else { |
|
211
|
1
|
|
|
|
|
15
|
warn "Invalid measure passed for coverwidth, should be 0.01 => 1.00\n"; |
|
212
|
|
|
|
|
|
|
} |
|
213
|
|
|
|
|
|
|
} |
|
214
|
42
|
|
|
|
|
701
|
return 1; |
|
215
|
|
|
|
|
|
|
} |
|
216
|
2
|
|
|
|
|
45
|
return 0; |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
has nocoverpage => (is => 'lazy', isa => Bool); |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub _build_nocoverpage { |
|
222
|
294
|
|
|
294
|
|
11896
|
my $self = shift; |
|
223
|
294
|
|
|
|
|
5452
|
return !!$self->header->{nocoverpage}; |
|
224
|
|
|
|
|
|
|
} |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
has notoc => (is => 'lazy', isa => Bool); |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub _build_notoc { |
|
229
|
292
|
|
|
292
|
|
10250
|
my $self = shift; |
|
230
|
292
|
|
|
|
|
5296
|
return !!$self->header->{notoc}; |
|
231
|
|
|
|
|
|
|
} |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
has nofinalpage => (is => 'lazy', isa => Bool); |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub _build_nofinalpage { |
|
236
|
292
|
|
|
292
|
|
10064
|
my $self = shift; |
|
237
|
292
|
|
|
|
|
5161
|
return !!$self->header->{nofinalpage}; |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
has impressum => (is => 'lazy', isa => Bool); |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
sub _build_impressum { |
|
243
|
292
|
|
|
292
|
|
10456
|
my $self = shift; |
|
244
|
292
|
|
|
|
|
5222
|
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
|
292
|
|
|
292
|
|
10466
|
sub _build_continuefootnotes { shift->_look_at_header('continuefootnotes') } |
|
251
|
298
|
|
|
298
|
|
10683
|
sub _build_centerchapter { shift->_look_at_header('centerchapter') } |
|
252
|
298
|
|
|
298
|
|
11598
|
sub _build_centersection { shift->_look_at_header('centersection') } |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
sub _look_at_header { |
|
255
|
888
|
|
|
888
|
|
2422
|
my ($self, $key) = @_; |
|
256
|
888
|
|
|
|
|
15797
|
return !!$self->header->{$key}; |
|
257
|
|
|
|
|
|
|
} |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
has topics => (is => 'lazy', isa => ArrayRef); |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
sub _build_topics { |
|
262
|
263
|
|
|
263
|
|
4576
|
my $self = shift; |
|
263
|
263
|
|
|
|
|
571
|
my @topics; |
|
264
|
263
|
|
|
|
|
920
|
foreach my $field (qw/cat sorttopics topics/) { |
|
265
|
789
|
|
|
|
|
1906
|
push @topics, $self->_parse_topic_or_author($field); |
|
266
|
|
|
|
|
|
|
} |
|
267
|
263
|
|
|
|
|
4962
|
return \@topics; |
|
268
|
|
|
|
|
|
|
} |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
has authors => (is => 'lazy', isa => ArrayRef); |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
sub _build_authors { |
|
273
|
263
|
|
|
263
|
|
5778
|
my $self = shift; |
|
274
|
263
|
|
|
|
|
611
|
my @authors; |
|
275
|
263
|
|
|
|
|
894
|
foreach my $field (qw/authors sortauthors/) { |
|
276
|
526
|
|
|
|
|
1903
|
push @authors, $self->_parse_topic_or_author($field); |
|
277
|
|
|
|
|
|
|
} |
|
278
|
263
|
|
|
|
|
4966
|
return \@authors; |
|
279
|
|
|
|
|
|
|
} |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
sub authors_as_html_list { |
|
282
|
71
|
|
|
71
|
1
|
1318
|
my $self = shift; |
|
283
|
71
|
|
|
|
|
1625
|
return $self->_html_strings($self->authors); |
|
284
|
|
|
|
|
|
|
} |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
sub topics_as_html_list { |
|
287
|
71
|
|
|
71
|
1
|
1358
|
my $self = shift; |
|
288
|
71
|
|
|
|
|
1539
|
return $self->_html_strings($self->topics); |
|
289
|
|
|
|
|
|
|
} |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
sub _html_strings { |
|
292
|
142
|
|
|
142
|
|
5078
|
my ($self, $list) = @_; |
|
293
|
142
|
|
|
|
|
302
|
my @out; |
|
294
|
142
|
|
|
|
|
389
|
foreach my $el (@$list) { |
|
295
|
26
|
|
|
|
|
10139
|
push @out, muse_format_line(html => $el); |
|
296
|
|
|
|
|
|
|
} |
|
297
|
142
|
|
|
|
|
8267
|
return @out; |
|
298
|
|
|
|
|
|
|
} |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
sub listing_title { |
|
301
|
259
|
|
|
259
|
1
|
604
|
my $self = shift; |
|
302
|
259
|
100
|
|
|
|
1434
|
if (length($self->listtitle)) { |
|
303
|
1
|
|
|
|
|
5
|
return $self->listtitle; |
|
304
|
|
|
|
|
|
|
} |
|
305
|
|
|
|
|
|
|
else { |
|
306
|
258
|
|
|
|
|
1315
|
return $self->title; |
|
307
|
|
|
|
|
|
|
} |
|
308
|
|
|
|
|
|
|
} |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
sub tex_metadata { |
|
311
|
258
|
|
|
258
|
1
|
6754
|
my $self = shift; |
|
312
|
|
|
|
|
|
|
my %out = ( |
|
313
|
|
|
|
|
|
|
title => $self->listing_title, |
|
314
|
258
|
|
|
|
|
5172
|
author => (scalar(@{$self->authors}) ? join('; ', @{$self->authors}) : $self->author), |
|
|
2
|
|
|
|
|
49
|
|
|
315
|
|
|
|
|
|
|
subject => $self->subtitle, |
|
316
|
258
|
100
|
|
|
|
1165
|
keywords => (scalar(@{$self->topics}) ? join('; ', @{$self->topics}) : ''), |
|
|
258
|
100
|
|
|
|
12315
|
|
|
|
8
|
|
|
|
|
369
|
|
|
317
|
|
|
|
|
|
|
); |
|
318
|
258
|
|
|
|
|
8745
|
foreach my $k (keys %out) { |
|
319
|
|
|
|
|
|
|
# just escape |
|
320
|
1032
|
|
|
|
|
69677
|
$out{$k} = Text::Amuse::InlineElement->new(string => $out{$k}, |
|
321
|
|
|
|
|
|
|
type => 'text', |
|
322
|
|
|
|
|
|
|
fmt => 'ltx')->stringify; |
|
323
|
|
|
|
|
|
|
} |
|
324
|
258
|
|
|
|
|
26477
|
return \%out; |
|
325
|
|
|
|
|
|
|
} |
|
326
|
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
sub _parse_topic_or_author { |
|
328
|
1315
|
|
|
1315
|
|
2931
|
my ($self, $field) = @_; |
|
329
|
1315
|
|
|
|
|
2804
|
my $header = $self->header; |
|
330
|
1315
|
|
|
|
|
4701
|
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
|
1315
|
50
|
|
|
|
3365
|
unless $fields{$field}; |
|
339
|
1315
|
|
|
|
|
2016
|
my @out; |
|
340
|
1315
|
100
|
|
|
|
3145
|
if (exists $header->{$field}) { |
|
341
|
22
|
|
|
|
|
56
|
my $string = $header->{$field}; |
|
342
|
22
|
50
|
33
|
|
|
118
|
if (defined $string and length $string) { |
|
343
|
22
|
|
|
|
|
81
|
my $separator = qr{\s*\,\s*}; |
|
344
|
22
|
100
|
|
|
|
109
|
if ($field eq 'cat') { |
|
|
|
100
|
|
|
|
|
|
|
345
|
4
|
|
|
|
|
14
|
$separator = qr{[\s;,]+}; |
|
346
|
|
|
|
|
|
|
} |
|
347
|
|
|
|
|
|
|
elsif ($string =~ m/\;/) { |
|
348
|
15
|
|
|
|
|
59
|
$separator = qr{\s*\;\s*}; |
|
349
|
|
|
|
|
|
|
} |
|
350
|
22
|
|
|
|
|
263
|
@out = grep { /\w/ } split(/$separator/, $string); |
|
|
61
|
|
|
|
|
220
|
|
|
351
|
|
|
|
|
|
|
} |
|
352
|
|
|
|
|
|
|
} |
|
353
|
1315
|
|
|
|
|
3880
|
return @out; |
|
354
|
|
|
|
|
|
|
} |
|
355
|
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
1; |