支持替换开头和结尾的引号为原本的引号
This commit is contained in:
@@ -70,8 +70,9 @@ CJK_LEFT_QUOTE = ["「", "『"]
|
||||
CJK_RIGHT_QUOTE = ["」", "』"]
|
||||
NEED_REPLACED_LEFT_QUOTE = ["“", "‘"]
|
||||
NEED_REPLACED_RIGHT_QUOTE = ["”", "’"]
|
||||
QUOTES = (("“", "”"), ("‘", "’"), ("\"", "\""), ("'", "'"), ("「", "」"), ("『", "』"))
|
||||
DIALOGUES = (
|
||||
("「", "」"), ("『", "』"), ("(", ")"),
|
||||
("「", "」", QUOTES), ("『", "』", QUOTES), ("(", ")", (("(", ")"), ("(", ")"))),
|
||||
)
|
||||
CIRCUS_SPECIAL = re.compile(r'(@[a-zA-Z0-9]+)')
|
||||
|
||||
@@ -160,8 +161,18 @@ def replace_quote_str(s) -> str:
|
||||
|
||||
|
||||
def check_dialogue(source: str, target: str) -> str:
|
||||
for left, right in DIALOGUES:
|
||||
for left, right, work in DIALOGUES:
|
||||
if source.startswith(left) and source.endswith(right):
|
||||
if not target.startswith(left):
|
||||
for wleft, _ in work:
|
||||
if target.startswith(wleft):
|
||||
target = left + target[len(wleft):]
|
||||
break
|
||||
if not target.endswith(right):
|
||||
for _, wright in work:
|
||||
if target.endswith(wright):
|
||||
target = target[:-len(wright)] + right
|
||||
break
|
||||
if not target.startswith(left):
|
||||
target = left + target
|
||||
if not target.endswith(right):
|
||||
|
||||
Reference in New Issue
Block a user