Skip to content

Commit

Permalink
Fix stl with tabs recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
mantas-done committed Apr 8, 2024
1 parent 38403de commit 7e75387
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Code/Converters/StlConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class StlConverter implements ConverterContract
{
public function canParseFileContent($file_content)
{
return preg_match('/^\d{2}:\d{2}:\d{2}:\d{2} , \d{2}:\d{2}:\d{2}:\d{2} , .+/m', $file_content) === 1;
return preg_match('/^\d{2}:\d{2}:\d{2}:\d{2}\s,\s\d{2}:\d{2}:\d{2}:\d{2}\s,.+/m', $file_content) === 1;
}

public function fileContentToInternalFormat($file_content, $original_file_content)
Expand Down
15 changes: 15 additions & 0 deletions tests/formats/StlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,19 @@ public function testTimesBiggerThan99HoursThrowException()
$subtitles->content('stl');
}

public function testClientFile()
{
$text = '
$FadeOut = 0
$TapeOffset = TRUE
$HorzAlign = Center
'."00:00:00:00\t,\t00:00:01:00\t,\ta
00:00:01:00\t,\t00:00:02:00\t,\tb
";

$actual = Subtitles::loadFromString($text)->getInternalFormat();
$expected = (new Subtitles())->add(0, 1, 'a')->add(1, 2, 'b')->getInternalFormat();
$this->assertInternalFormatsEqual($expected, $actual);
}
}

0 comments on commit 7e75387

Please sign in to comment.