Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline subtitles #2

Closed
frost768 opened this issue Apr 21, 2023 · 0 comments · Fixed by #3
Closed

Multiline subtitles #2

frost768 opened this issue Apr 21, 2023 · 0 comments · Fixed by #3
Labels
bug Something isn't working

Comments

@frost768
Copy link
Contributor

frost768 commented Apr 21, 2023

First of all thanks for this great library and conversion to typescript.
The problem is that the regex in vtt doesn't capture the first line of a multiline subtitle.
For example:

WEBVTT

00:00:00.000 --> 00:00:10.000 position:45%,line-right align:center size:35%
- Hey
- Hi

00:00:11.000 --> 00:00:20.000
- Hey
- Hi

The first caption's output is '-Hey -Hi' but the second one's is just '- Hi'.
I believe it is related to \s?.*\r?\n regex before the text group ([\s\S]*).
It matches with the first line and completely disregards it.
Explanation:
In the first caption;

  • `\s?' matches with the space between the times and style
  • .*\r?\n matches with the style and the new line

In the second caption;

  • `\s?' doesn't match anything because there is no space
  • .*\r?\n matches with - Hey because it takes every character until it comes across with a new line which also happens to be the first line of the caption.

https://github.com/leranjun/subsrt-ts/blob/862a66da48ef883b328ae6ceb5e3b4627fed5f5c/lib/format/vtt.ts#L40-L42

@rakuzen25 rakuzen25 linked a pull request Apr 27, 2023 that will close this issue
@rakuzen25 rakuzen25 added the bug Something isn't working label Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants