Skip to content

Commit f318746

Browse files
committed
Check format of 校正字頭 in patches.csv
1 parent 956f499 commit f318746

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

build.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,14 @@ def main():
180180
assert patch.校正字頭, (
181181
f'patching 小韻 #{原書小韻號}/{小韻字號} 字 "{patch.原字頭}", but 校正字頭 is missing'
182182
)
183-
# TODO verify `patch.校正字頭`
183+
if patch.校正字頭.startswith('['):
184+
assert re.fullmatch(r'\[.+/.+\]', patch.校正字頭), (
185+
f'invalid 校正字頭: "{patch.校正字頭}"'
186+
)
187+
if '~' in patch.校正字頭:
188+
assert not 字頭.startswith('['), (
189+
f'cannot use "~" in 校正字頭 when 字頭 contains correction: "{字頭}"'
190+
)
184191
字頭 = patch.校正字頭.replace('~', 字頭)
185192
if 字頭.endswith('/-]'):
186193
字頭當刪 = patch.當刪說明 or '當刪'

0 commit comments

Comments
 (0)