From 3965486152a58c67379e5e62ef0a4a6e135d371e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Lide=CC=81n?= Date: Wed, 27 Nov 2024 15:54:59 +0100 Subject: [PATCH] fix(srt): reader adds newline to multi-line cues --- src/main/python/ttconv/srt/reader.py | 3 --- src/test/python/test_srt_reader.py | 33 ++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) 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..8624877b 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,31 @@ def test_long_hours(self): 363601, doc.get_body().first_child().first_child().get_end() ) - + + def test_starts_with_span_single_line(self): + f = io.StringIO(r"""1 +101:00:00,000 --> 101:00:01,000 +Hello +""") + doc = to_model(f) + + self.assertIsInstance( + doc.get_body().first_child().first_child().first_child(), + model.Span + ) + + def test_starts_with_span_multi_line(self): + f = io.StringIO(r"""1 +101:00:00,000 --> 101:00:01,000 +Hello +World +""") + doc = to_model(f) + + self.assertIsInstance( + doc.get_body().first_child().first_child().first_child(), + model.Span + ) if __name__ == '__main__': unittest.main()