Skip to content

Commit 38cd7b0

Browse files
Merge pull request #1491 from benoit-pierre/handle_2#
system/english_stenotype: improve RTF/CRE compatibility
2 parents ca5cf77 + b33e875 commit 38cd7b0

File tree

8 files changed

+33
-5
lines changed

8 files changed

+33
-5
lines changed

news.d/feature/1491.core.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve “English stenotype” system compatibility with RTF/CRE spec: support arbitrary placement of the number sign when parsing steno (e.g. `18#`, `#18`, and `1#8` are all valid and equivalent).

plover/steno.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ class Stroke(BaseStroke):
3030
UNDO_STROKE = None
3131

3232
@classmethod
33-
def setup(cls, keys, implicit_hyphen_keys, number_key, numbers, undo_stroke):
33+
def setup(cls, keys, implicit_hyphen_keys, number_key,
34+
numbers, feral_number_key, undo_stroke):
3435
if number_key is None:
3536
assert not numbers
3637
numbers = None
37-
super().setup(keys, implicit_hyphen_keys, number_key, numbers)
38+
super().setup(keys, implicit_hyphen_keys, number_key, numbers, feral_number_key)
3839
cls._class = type(cls.__name__, (cls,), {'_helper': cls._helper})
3940
cls._class._class = cls._class
4041
cls._class.PREFIX_STROKE = cls.PREFIX_STROKE = cls.from_integer(0)

plover/system/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def _suffix_keys(keys):
4646
'KEY_ORDER' : lambda mod: _key_order(mod.KEYS, mod.NUMBERS),
4747
'NUMBER_KEY' : lambda mod: mod.NUMBER_KEY,
4848
'NUMBERS' : lambda mod: dict(mod.NUMBERS),
49+
'FERAL_NUMBER_KEY' : lambda mod: getattr(mod, 'FERAL_NUMBER_KEY', False),
4950
'SUFFIX_KEYS' : lambda mod: _suffix_keys(mod.SUFFIX_KEYS),
5051
'UNDO_STROKE_STENO' : lambda mod: mod.UNDO_STROKE_STENO,
5152
'IMPLICIT_HYPHEN_KEYS' : lambda mod: set(mod.IMPLICIT_HYPHEN_KEYS),
@@ -67,6 +68,7 @@ def setup(system_name):
6768
system_symbols[symbol] = init(system_mod)
6869
system_symbols['NAME'] = system_name
6970
globals().update(system_symbols)
70-
Stroke.setup(KEYS, IMPLICIT_HYPHEN_KEYS, NUMBER_KEY, NUMBERS, UNDO_STROKE_STENO)
71+
Stroke.setup(KEYS, IMPLICIT_HYPHEN_KEYS, NUMBER_KEY, NUMBERS,
72+
FERAL_NUMBER_KEY, UNDO_STROKE_STENO)
7173

7274
NAME = None

plover/system/english_stenotype.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
'-T': '-9',
2828
}
2929

30+
# For RTF/CRE support:
31+
#
32+
# IV.C.1.iii Number Bar
33+
# If the number bar was used in a stroke, the stroke contains a number sign
34+
# to indicate that. T͟h͟e͟ ͟n͟u͟m͟b͟e͟r͟ ͟s͟i͟g͟n͟ ͟m͟a͟y͟ ͟b͟e͟ ͟a͟n͟y͟w͟h͟e͟r͟e͟ ͟w͟i͟t͟h͟i͟n͟ ͟t͟h͟e͟ ͟s͟t͟r͟o͟k͟e͟, […]
35+
#
36+
FERAL_NUMBER_KEY = True
37+
3038
UNDO_STROKE_STENO = '*'
3139

3240
ORTHOGRAPHY_RULES = [

reqs/constraints.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pep517==0.12.0
3434
pip==21.3.1
3535
pkginfo==1.7.1
3636
plover-plugins-manager==0.7.0
37-
plover-stroke==1.0.1
37+
plover-stroke==1.1.0
3838
plover-treal==1.0.1
3939
pluggy==1.0.0
4040
py==1.10.0

reqs/dist.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
appdirs>=1.3.0
22
appnope>=0.1.0; "darwin" in sys_platform
3-
plover-stroke>=1.0.0
3+
plover-stroke>=1.1.0
44
pyobjc-core>=4.0; "darwin" in sys_platform
55
pyobjc-framework-Cocoa>=4.0; "darwin" in sys_platform
66
pyobjc-framework-Quartz>=4.0; "darwin" in sys_platform

test/test_rtfcre_dict.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,15 @@ def rtf_load_test(*spec, xfail=False):
436436
'''
437437
'TEFT': ''
438438
'''),
439+
440+
# RTF/CRE spec allow the number key letter anywhere...
441+
lambda: rtf_load_test(
442+
r'''
443+
{\*\cxs 2#}2
444+
445+
'2': '2',
446+
'''),
447+
439448
)
440449

441450
def rtf_save_test(dict_entries, rtf_entries):

test/test_steno.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
lambda: ('#A', ('5',)),
4646
lambda: ('#0', ('0',)),
4747
lambda: ('#6', ('-6',)),
48+
# RTF/CRE spec allow the number key letter anywhere…
49+
lambda: ('#WS', ('#W-S',)),
50+
lambda: ('W#S', ('#W-S',)),
51+
lambda: ('W-S#', ('#W-S',)),
52+
lambda: ('S#A', ('15',)),
53+
lambda: ('2#', ('2',)),
4854
# Implicit hyphens.
4955
lambda: ('SA-', ('SA',)),
5056
lambda: ('SA-R', ('SAR',)),
@@ -57,6 +63,7 @@
5763
lambda: ('S-*R', (ValueError, ('S-*R',))),
5864
lambda: ('-O-', (ValueError, ('-O-',))),
5965
lambda: ('-O', (ValueError, ('-O',))),
66+
lambda: ('#WS#', (ValueError, ('#WS#',))),
6067
)
6168

6269
@parametrize(NORMALIZE_TESTS)

0 commit comments

Comments
 (0)