Browse Source

* Subtitle::SSA : improve section switching

master
Alex 'AdUser' Z 6 years ago
parent
commit
4d77036a50
  1. 11
      lib/Subtitle/SSA.pm

11
lib/Subtitle/SSA.pm

@ -44,11 +44,11 @@ sub parse {
study $line; study $line;
# check section switch # check section switch
if ($line =~ m/^\s*\[(.+)\]\s*/o) { if ($line =~ m/^\s*\[\s*([a-z0-9+ ]+)\s*\]\s*$/io) {
my $name = $1; my $name = lc($1);
if ($name =~ m{script \s+ info}oix) { if ($name =~ m{script \s+ info}oix) {
$section = 'header'; $section = 'header';
} elsif ($name =~ m{events}oi) { } elsif ($name eq 'events') {
$section = 'events'; $section = 'events';
} elsif ($name =~ m{v4(\+)? \s+ styles}oix) { } elsif ($name =~ m{v4(\+)? \s+ styles}oix) {
$section = 'styles'; $section = 'styles';
@ -57,9 +57,10 @@ sub parse {
$self->log(warn => "Set type to $self->{type} because of line $linenum (fallback mode)"); $self->log(warn => "Set type to $self->{type} because of line $linenum (fallback mode)");
} }
} else { } else {
undef $section; $section = 'unknown';
$self->log(debug => "Unknown section at line $linenum: $line"); $self->log(warn => "Unknown section at line $linenum: $line");
} }
$self->log(debug => "section changed to [$section] at line $linenum");
next; next;
} }
# #

Loading…
Cancel
Save