Skip to content

Commit

Permalink
Merge pull request #334 from pbs/OCTO-11001=space-to-mid-row-codes
Browse files Browse the repository at this point in the history
OCTO-11001=space-to-mid-row-codes
  • Loading branch information
OlteanuRares authored May 14, 2024
2 parents 0ff80f4 + 3fe7d5b commit 5692578
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 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.7
^^^^^
- The cursor moves automatically one column to the right after each character or Mid-Row Code received.

2.2.6
^^^^^
- Pass the caption cue time with all error messages.
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
# built documents.
#
# The short X.Y version.
version = '2.2.6'
version = '2.2.6.dev3'
# The full version, including alpha/beta/rc tags.
release = '2.2.6'
release = '2.2.6.dev3'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
6 changes: 6 additions & 0 deletions pycaption/scc/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,3 +1046,9 @@ def _restructure_bytes_to_position_map(byte_to_pos_map):
'└': ["+"],
'┘': ["+"]
}

MID_ROW_CODES = [
"9120", "91a1", "91a2", "9123", "91a4", "9125", "9126",
"91a7", "91a8", "9129", "912a", "91ab", "912c", "91ad",
"97ae", "972f", "91ae", "912f", "94a8"
]
11 changes: 9 additions & 2 deletions pycaption/scc/specialized_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
)
from .constants import (
PAC_BYTES_TO_POSITIONING_MAP, COMMANDS, PAC_TAB_OFFSET_COMMANDS,
MICROSECONDS_PER_CODEWORD, INCONVERTIBLE_TO_ASCII_EXTENDED_CHARS_ASSOCIATION
MICROSECONDS_PER_CODEWORD, INCONVERTIBLE_TO_ASCII_EXTENDED_CHARS_ASSOCIATION,
MID_ROW_CODES
)

PopOnCue = collections.namedtuple("PopOnCue", "buffer, start, end")
Expand Down Expand Up @@ -254,7 +255,7 @@ def create_and_store(self, node_buffer, start, end=0):
layout_info = _get_layout_from_tuple(instruction.position)
caption.nodes.append(
CaptionNode.create_text(
instruction.get_text(), layout_info=layout_info),
instruction.text, layout_info=layout_info),
)
caption.layout_info = layout_info

Expand Down Expand Up @@ -346,6 +347,12 @@ def interpret_command(self, command):

text = COMMANDS.get(command, '')

if command in MID_ROW_CODES:
for node in self._collection[::-1]:
if node.is_text_node():
node.text += ' '
break

if 'italic' in text:
if 'end' not in text:
self._collection.append(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

setup(
name='pycaption',
version='2.2.6',
version='2.2.6.dev3',
description='Closed caption converter',
long_description=open(README_PATH).read(),
author='Joe Norton',
Expand Down
6 changes: 3 additions & 3 deletions tests/test_scc.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ def test_skip_extended_characters_ascii_duplicate(

def test_skip_duplicate_tab_offset(self, sample_scc_duplicate_tab_offset):
expected_lines = [
'[Radio reporter]',
'The I-10 Santa Monica Freeway',
'[Radio reporter] ',
'The I-10 Santa Monica Freeway ',
'westbound is jammed,',
'due to a three-car accident',
'due to a three-car accident ',
'blocking lanes 1 and 2',
]

Expand Down

0 comments on commit 5692578

Please sign in to comment.