From e01404f18e03ae5d00cc97af5cbe1d48e3946108 Mon Sep 17 00:00:00 2001 From: fish Date: Sun, 12 Jul 2026 22:38:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=81=A2=E5=A4=8DiCloud=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E5=8E=9F=E5=A7=8B=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Note/FormatNoteViewController.swift | 33 ++++++++++------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/Note/FormatNoteViewController.swift b/Note/FormatNoteViewController.swift index 455be96..ba4d9cb 100644 --- a/Note/FormatNoteViewController.swift +++ b/Note/FormatNoteViewController.swift @@ -208,30 +208,19 @@ class FormatNoteViewController: UIViewController { content = content.replacingOccurrences(of: old, with: new) } + content = content.replacingOccurrences(of: "。", with: "。\n") + content = content.replacingOccurrences(of: "?", with: "?\n") + content = removeEmptyLines(content) + content = content.replacingOccurrences(of: ":\\s*", with: ":\n\n", options: .regularExpression) + content = content.replacingOccurrences(of: "。", with: "。\n") + content = content.replacingOccurrences(of: "?", with: "?\n") + content = content.replacingOccurrences(of: ":\n\n", with: ":") + content = content.replacingOccurrences(of: ":一、", with: ":\n\n一、") + content = content.replacingOccurrences(of: " ", with: "") + content = content.replacingOccurrences(of: "---", with: "---\n") content = content.replacingOccurrences(of: "日星期", with: "日 星期") - - // 保留原始段落结构 - let paragraphs = content.components(separatedBy: .newlines) - .split(separator: "", omittingEmptySubsequences: false) - .map { $0.joined(separator: "\n") } - - let formattedParagraphs = paragraphs.map { paragraph -> String in - var p = paragraph - p = p.replacingOccurrences(of: "。", with: "。\n") - p = p.replacingOccurrences(of: "?", with: "?\n") - p = removeEmptyLines(p) - p = p.replacingOccurrences(of: ":\\s*", with: ":\n\n", options: .regularExpression) - p = p.replacingOccurrences(of: "。", with: "。\n") - p = p.replacingOccurrences(of: "?", with: "?\n") - p = p.replacingOccurrences(of: ":\n\n", with: ":") - p = p.replacingOccurrences(of: ":一、", with: ":\n\n一、") - p = p.replacingOccurrences(of: "---", with: "---\n") - p = removeEmptyLines(p) - return p - } - - content = formattedParagraphs.joined(separator: "\n\n") content = "# " + content + content = insertEmptyLineAfterFirstLine(content) return content }