190 |
} |
} |
191 |
|
|
192 |
sub insertAtom { |
sub insertAtom { |
193 |
my ($out, $index, $ref_args) = @_; |
my ($out, $index, $ref_args) = @_; |
194 |
|
$index >= @{$out->{atoms}} and return appendAtom($out, $ref_args); |
195 |
my %args = %$ref_args; |
my %args = %$ref_args; |
196 |
splice(@{$out->{atoms}}, $index, 0, {}); |
splice(@{$out->{atoms}}, $index, 0, {}); |
197 |
$args{sections} ||= @{$out->{atoms}}[$index-1]->{sections}; |
$args{sections} ||= @{$out->{atoms}}[$index-1]->{sections}; |
198 |
|
$args{sections} ||= []; |
199 |
eval($templates{$out->{template_name}}{edit_atom}); |
eval($templates{$out->{template_name}}{edit_atom}); |
200 |
# validate($out, @{$out->{atoms}}[$index]); |
# validate($out, @{$out->{atoms}}[$index]); |
201 |
} |
} |
252 |
my ($out, $file) = @_; |
my ($out, $file) = @_; |
253 |
my @file = @$file; |
my @file = @$file; |
254 |
my $item = 0; |
my $item = 0; |
255 |
my $next_item = 0; |
# my $next_item = 0; |
256 |
my $matched; |
my $matched; |
257 |
my $template_name = $out->{template_name}; |
my $template_name = $out->{template_name}; |
258 |
my @out_atoms; |
my @out_atoms; |
309 |
my $atom = $out_atoms[$item]; |
my $atom = $out_atoms[$item]; |
310 |
eval ( $_ ); |
eval ( $_ ); |
311 |
$@ and die qq(error while applying the rule '$_' to '$in' : $@); |
$@ and die qq(error while applying the rule '$_' to '$in' : $@); |
312 |
$next_item = $matched && !$keep_atom; |
# $next_item = $matched && !$keep_atom; |
313 |
$matched and last; |
$matched and last; |
314 |
} |
} |
315 |
# validate($out, $out_atoms[$item]); |
# validate($out, $out_atoms[$item]); |
316 |
$in !~ /^\s*$/ and push @{$out_atoms[$item]->{invalid}}, $in; |
$in !~ /^\s*$/ and push @{$out_atoms[$item]->{invalid}}, $in; |
317 |
if ($next_item) { |
$keep_atom or $item++; |
318 |
$item++; |
# if (!$keep_atom) { |
319 |
$next_item = 0; |
# $item++; |
320 |
} |
# $next_item = 0; |
321 |
|
# } |
322 |
} |
} |
323 |
$out->{atoms} = [@out_atoms]; |
$out->{atoms} = [@out_atoms]; |
324 |
} |
} |