From 1cf098508d13520b9b3c34f7ca9f9ee2ea66d50d Mon Sep 17 00:00:00 2001 From: root Date: Wed, 14 Sep 2022 12:58:11 +0530 Subject: [PATCH] fix(srt): consider whitespace texts as text --- lib/captions/formats/srt.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/captions/formats/srt.rb b/lib/captions/formats/srt.rb index c6d35a6..7532f1a 100644 --- a/lib/captions/formats/srt.rb +++ b/lib/captions/formats/srt.rb @@ -10,9 +10,10 @@ def parse count += 1 line = @file.gets break if line.nil? ## End of file - line.strip! + line.chomp! case state when :new_cue + line.strip! next if line.empty? ## just another blank line, remain in new_cue state begin cue = Cue.new(Integer(line)) @@ -21,6 +22,7 @@ def parse end state = :time when :time + line.strip! raise InvalidSubtitle, "Invalid Time Format at line #{count}" unless is_time?(line) start_time, end_time = get_time(line) cue.set_time(start_time, end_time) @@ -32,6 +34,7 @@ def parse cue = nil state = :new_cue else + line.strip! cue.add_text(line) end end