diff --git a/src/vttParser.ts b/src/vttParser.ts index 8491914..66607a9 100644 --- a/src/vttParser.ts +++ b/src/vttParser.ts @@ -67,7 +67,7 @@ const VttMachine: () => Machine = () => ({ const { tokens, pos } = params; if (tokens.length <= pos) { return { next: TRANSITION_NAMES.FINISH, params }; - } else if(tokens[pos].includes(":")){ + } else if(tokens[pos].includes(":") && !tokens[pos].includes("-->") ){ return { next: TRANSITION_NAMES.LEGACY_HEADER, params: { ...params, pos: pos + 1 } }; } else { return { next: TRANSITION_NAMES.ID_OR_NOTE_OR_STYLE_OR_REGION, params }; diff --git a/test/index.test.ts b/test/index.test.ts index 10ff886..f4ee08c 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -7,6 +7,7 @@ import vttMultiWhitespaces from './vttMultiWhitespaces'; import vttWithEmptyTextLines from './vttWithEmptyTextLines'; import vttWithMissingNewLineInLastLine from './vttWithMissingNewLineInLastLine'; import vtt from './vtt'; +import vttDirectTimestamp from './vttDirectTimestamp'; import vttWithLegacyMetaHeader from './vttWithLegacyMetaHeader'; import vttWithRegionHeader from './vttWithRegion'; import vttWithoutIdentifier from './vttWithoutIdentifier'; @@ -33,6 +34,7 @@ describe('srt-vtt-parser', () => { ${vtt} | ${result} | ${'should parse simple vtt file'} ${vttMultiWhitespaces} | ${result} | ${'should parse vtt file with multiple whitespaces'} ${vttWithMissingNewLineInLastLine} | ${result} | ${'should parse vtt file even the last line does not have a new line'} + ${vttDirectTimestamp} | ${resultWithoutId} | ${'should parse vtt file with direct time stamp'} ${vttWithEmptyTextLines} | ${resultWithEmptyTextLines} | ${'should parse vtt file with empty text lines'} ${vttWithoutIdentifier} | ${resultWithoutId} | ${'should parse vtt file without identifier'} ${vttWithMixedIdentifier} | ${resultWithMixedId} | ${'should parse vtt file with mixed identifier'} @@ -49,10 +51,10 @@ describe('srt-vtt-parser', () => { }); it('parse whole srt file', () => { - // console.warn(parse(driveSrt)); + console.warn(parse(driveSrt)); }); it('parse whole vtt file', async () => { - // console.warn(await parse(pulpfictionVtt)); + console.warn(await parse(pulpfictionVtt)); }); }); diff --git a/test/vttDirectTimestamp.ts b/test/vttDirectTimestamp.ts new file mode 100644 index 0000000..52ee4c6 --- /dev/null +++ b/test/vttDirectTimestamp.ts @@ -0,0 +1,11 @@ +export default `WEBVTT +00:01:42.821 --> 00:01:44.289 +(SIREN WAILING IN DISTANCE) +multiline test + +00:01:45.365 --> 00:01:48.084 +DRIVER: There's 100,000 streets in this city. + +00:01:49.077 --> 00:01:51.421 +You don't need to know the route. +` diff --git a/test/vttWithEmptyTextLines.ts b/test/vttWithEmptyTextLines.ts index b94488b..976df1c 100644 --- a/test/vttWithEmptyTextLines.ts +++ b/test/vttWithEmptyTextLines.ts @@ -1,5 +1,4 @@ export default `WEBVTT - 1 00:01:42.821 --> 00:01:44.289 (SIREN WAILING IN DISTANCE)