Recently Written · git

subread-extension

Show your own .srt over a YouTube video, in time with it. Chrome and Firefox.

git clone https://github.com/equwal/subread-extension

Log | Files | Refs


commit 5511406cd6503dec1dfa2886fbfbadcb1c3c7114
equwal <truex@equwal.com>
2026-09-22 14:05:23 -0700

Test the subtitle reader with the text of five languages

The reader must give the text of a cue back as it is. Only English and
Japanese had a test, so a defect in another language was not found by a test.

Add a case that reads a file with lines of English, Portuguese, Spanish,
Russian and Japanese, and asks for the cue of a moment in each line. The
accents, the inverted marks, the guillemets and the ideographic space must
come back unchanged.

 tests/srt.test.cjs | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff --git a/tests/srt.test.cjs b/tests/srt.test.cjs
index df5e956..b27de93 100644
--- a/tests/srt.test.cjs
+++ b/tests/srt.test.cjs
@@ -12,6 +12,20 @@ test('an .srt is read: numbers, stamps, text of more than one line, tags removed
   ]);
 });
 
+test('the text of each checked language is kept as it is: accents, inverted marks, quotes, kana', () => {
+  const lines = {
+    en: 'It was a dark night; the rain fell.',
+    pt: '— Não me parece bonito — disse ela, à porta.',
+    es: '¿Qué es esto? ¡Ñandú, señor Quijote!',
+    ru: '«Ёлка, — сказал он, — и её огни».',
+    ja: '「女のいない男たち」 東京で暮らしている。',
+  };
+  const source = Object.values(lines).map((text, i) => `${i + 1}\n00:00:0${i},000 --> 00:00:0${i},900\n${text}\n`).join('\n');
+  const cues = parse(source);
+  assert.deepEqual(cues.map((c) => c.text), Object.values(lines));
+  Object.values(lines).forEach((text, i) => assert.equal(cueAt(cues, i + 0.5).text, text));
+});
+
 test('a .vtt is read too, and what is not a cue is passed over', () => {
   const cues = parse('WEBVTT\n\nNOTE made by hand\n\n00:01.000 --> 00:02.5\nHello\n\nbroken --> block\nx\n\n3\n00:00:09,000 --> 00:00:08,000\nends before it starts\n');
   assert.deepEqual(cues, [{ start: 1, end: 2.5, text: 'Hello' }]);