diff --git a/src/main/python/ttconv/srt/reader.py b/src/main/python/ttconv/srt/reader.py index 177e93d8..84f906af 100644 --- a/src/main/python/ttconv/srt/reader.py +++ b/src/main/python/ttconv/srt/reader.py @@ -256,9 +256,6 @@ def to_model(data_file: typing.IO, _config = None, progress_callback=lambda _: N div.push_child(current_p) subtitle_text = "" - if state is _State.TEXT_MORE: - current_p.push_child(model.Br(current_p.get_doc())) - subtitle_text += line state = _State.TEXT_MORE diff --git a/src/test/python/test_srt_reader.py b/src/test/python/test_srt_reader.py index 7ac887f1..69bb410b 100644 --- a/src/test/python/test_srt_reader.py +++ b/src/test/python/test_srt_reader.py @@ -31,6 +31,7 @@ from ttconv.srt.reader import to_model import ttconv.style_properties as styles +import ttconv.model as model @@ -78,7 +79,7 @@ def test_bold(self): def test_blank_lines(self): # from https://en.wikipedia.org/wiki/SubRip SAMPLE = """ - + 1 00:02:16,612 --> 00:02:19,376 Senator, we're making @@ -135,7 +136,7 @@ def test_italic_alt(self): if e.get_style(styles.StyleProperties.FontStyle) == styles.FontStyleType.italic: break else: - self.fail() + self.fail() def test_underline(self): f = io.StringIO(r"""1 @@ -161,7 +162,7 @@ def test_underline_alt(self): if text_decoration is not None and text_decoration.underline: break else: - self.fail() + self.fail() def test_blue(self): f = io.StringIO(r"""1 @@ -205,7 +206,35 @@ def test_long_hours(self): 363601, doc.get_body().first_child().first_child().get_end() ) - + + def test_single_line_text(self): + f = io.StringIO(r"""1 +101:00:00,000 --> 101:00:01,000 +Hello +""") + doc = to_model(f) + + p_children = list(doc.get_body().first_child().first_child()) + self.assertEqual(len(p_children), 1) + self.assertIsInstance(p_children[0], model.Span) + self.assertEqual(p_children[0].first_child().get_text(), "Hello") + + def test_multiline_text(self): + f = io.StringIO(r"""1 +101:00:00,000 --> 101:00:01,000 +Hello +World +""") + doc = to_model(f) + + p_children = list(doc.get_body().first_child().first_child()) + self.assertEqual(len(p_children), 3) + self.assertIsInstance(p_children[0], model.Span) + self.assertEqual(p_children[0].first_child().get_text(), "Hello") + self.assertIsInstance(p_children[1], model.Br) + self.assertIsInstance(p_children[2], model.Span) + self.assertEqual(p_children[2].first_child().get_text(), "World") + if __name__ == '__main__': unittest.main()