Skip to content

Commit ee954c7

Browse files
committed
Improve skip of empty lines #28
1 parent 7d84c01 commit ee954c7

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

webvtt/parsers.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,14 @@ def _compute_blocks(self, lines):
167167
blocks = []
168168

169169
for index, line in enumerate(lines, start=1):
170-
# clean up exstraneous whitespace
171-
final_line = line.strip()
172-
173-
# Remove empty lines
174-
if final_line:
170+
if line:
175171
if not blocks:
176172
blocks.append(Block(index))
177173
if not blocks[-1].lines:
174+
if not line.strip():
175+
continue
178176
blocks[-1].line_number = index
179-
blocks[-1].lines.append(final_line)
177+
blocks[-1].lines.append(line)
180178
else:
181179
blocks.append(Block(index))
182180

@@ -198,7 +196,7 @@ def _parse_cue_block(self, block):
198196
'{} in line {}'.format(e, block.line_number + line_number))
199197
else:
200198
additional_blocks = self._compute_blocks(
201-
['WEBVTT', '\n'] + block.lines[line_number:]
199+
['WEBVTT', ''] + block.lines[line_number:]
202200
)
203201
break
204202
elif line_number == 0:

0 commit comments

Comments
 (0)