@@ -378,12 +378,16 @@ def eventTagsSplit(assInfo: dict, changeOnly: bool = True) -> dict:
378
378
reVector2 = re .compile (r'\{.*?\\p[1-9]\d*.*?\}' )
379
379
reEffect = re .compile (r'\{.*?(?:\\b[1-9]00|\\b[0-1]|\\i[0-1]|\\fn|\\r).*?\}' )
380
380
reIBon = re .compile (r'\\b[1-9]00|\\b[0-1]|\\i[0-1]|\\fn|\\r' )
381
+ allTags = re .compile (r'\{.*?\}' )
382
+ effectDel = re .compile (r'\{.*?\}|\\[nNhs]|\n' )
383
+ findR = re .compile (r'\\r.*?[\\\}]' )
384
+ findB = re .compile (r'\\b[7-9]00|\\b1' )
385
+ findFn = re .compile (r'\\fn.*?[\\\}]' )
381
386
382
387
for i in range (0 , len (events )):
383
388
if events [i ]['Event' ] != 'Dialogue' :
384
389
continue
385
390
eventftext = events [i ]['Text' ]
386
- effectDel = r'\{.*?\}|\\[nNhs]|\n'
387
391
textremain = ''
388
392
# 矢量绘图处理,如果发现有矢量表达,从字符串中删除这一部分
389
393
# 这一部分的工作未经详细验证,作用也不大
@@ -417,7 +421,7 @@ def eventTagsSplit(assInfo: dict, changeOnly: bool = True) -> dict:
417
421
# 首先查找蕴含有启用粗体/斜体标记的特效标签
418
422
if re .search (reEffect , eventftext ) is not None :
419
423
lastfind = 0
420
- allfind = re .findall (r'\{.*?\}' , eventftext )
424
+ allfind = re .findall (allTags , eventftext )
421
425
eventftext2 = eventftext
422
426
# 在所有特效标签中寻找
423
427
# 然后分别确认该特效标签的适用范围,以准确将字体子集化b
@@ -429,7 +433,7 @@ def eventTagsSplit(assInfo: dict, changeOnly: bool = True) -> dict:
429
433
addbold = lfb
430
434
additalic = lfi
431
435
# 不管有没有 \r 标签,先获取了再说
432
- rstylel = re .findall (r'\\r.*?[\\\}]' , st )
436
+ rstylel = re .findall (findR , st )
433
437
rfn = lfn
434
438
rfb = lfb
435
439
rfi = lfi
@@ -451,7 +455,7 @@ def eventTagsSplit(assInfo: dict, changeOnly: bool = True) -> dict:
451
455
452
456
# 统一获取标签位置
453
457
pos_b1 = - 1
454
- fbopen = re .findall (r'\\b[7-9]00|\\b1' , st )
458
+ fbopen = re .findall (findB , st )
455
459
if len (fbopen ) > 0 :
456
460
pos_b1 = st .rfind (fbopen [- 1 ])
457
461
pos_b0 = max ([st .rfind ('\\ b0' ), st .rfind ('\\ b\\ ' ), st .rfind ('\\ b}' )])
@@ -479,7 +483,7 @@ def eventTagsSplit(assInfo: dict, changeOnly: bool = True) -> dict:
479
483
480
484
# 处理 \fn 标签 和 \r 标签
481
485
if pos_fn > - 1 :
482
- fnf = re .findall (r'\\fn.*?[\\\}]' , st )
486
+ fnf = re .findall (findFn , st )
483
487
if len (fnf ) > 0 and pos_fn > pos_r :
484
488
fnn = fnf [- 1 ].split ('\\ ' )[1 ].rstrip ('}' )[2 :].lstrip ('@' )
485
489
if len (fnn ) == 0 :
0 commit comments