From 864d3dda69660cd1967452cc129662b4833d99ef Mon Sep 17 00:00:00 2001 From: lifegpc Date: Mon, 5 Jan 2026 16:13:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9B=BF=E6=8D=A2=E5=BC=80?= =?UTF-8?q?=E5=A4=B4=E5=92=8C=E7=BB=93=E5=B0=BE=E7=9A=84=E5=BC=95=E5=8F=B7?= =?UTF-8?q?=E4=B8=BA=E5=8E=9F=E6=9C=AC=E7=9A=84=E5=BC=95=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- m3tpostprocess.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/m3tpostprocess.py b/m3tpostprocess.py index ac68cd1..3ff0952 100644 --- a/m3tpostprocess.py +++ b/m3tpostprocess.py @@ -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):