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

Loading…
Cancel
Save