Skip to content

Commit

Permalink
OCTO-11088-fix-text-positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
OlteanuRares committed Sep 16, 2024
1 parent 0af80fc commit e83a870
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Changelog
---------
2.2.14
^^^^^^
- Fix an issue with WebVTT writer text positioning on break inside a cue.

2.2.13
^^^^^^
- Mid-row codes only add spaces only if there isn't one before.
Expand Down
11 changes: 2 additions & 9 deletions pycaption/webvtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ def _group_cues_by_layout(self, nodes, caption_set):
return []

current_layout = None
current_node = None

# A list with layout groups. Since WebVTT only support positioning
# for different cues, each layout group has to be represented in a
Expand All @@ -408,18 +407,12 @@ def _group_cues_by_layout(self, nodes, caption_set):
if s and current_layout and node.layout_info != current_layout:
# If the positioning changes from one text node to
# another, a new WebVTT cue has to be created.
row, column = node.position if node.position else (0, 0)
prev_row, prev_column = (
current_node.position if current_node.position else (0, 0)
)
if row != prev_row + 1:
layout_groups.append((s, current_layout))
s = ""
layout_groups.append((s, current_layout))
s = ""
# ATTENTION: This is where the plain unicode node content is
# finally encoded as WebVTT.
s += self._encode_illegal_characters(node.content) or " "
current_layout = node.layout_info
current_node = node
elif node.type_ == CaptionNode.STYLE:
resulting_style = self._calculate_resulting_style(
node.content, caption_set
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name="pycaption",
version="2.2.13",
version="2.2.14.dev1",
description="Closed caption converter",
long_description=open(README_PATH).read(),
author="Joe Norton",
Expand Down

0 comments on commit e83a870

Please sign in to comment.