From 0c202ac284a15521dc608b55451731ca41e65c00 Mon Sep 17 00:00:00 2001 From: fish Date: Sun, 12 Jul 2026 21:04:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=88=B0=20iOS=20=E7=AB=AF=E5=B9=B6=E5=88=A0?= =?UTF-8?q?=E9=99=A4=20Python=20=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Note/FormatLogViewController.swift | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Note/FormatLogViewController.swift b/Note/FormatLogViewController.swift index deea6b1..9e6448e 100644 --- a/Note/FormatLogViewController.swift +++ b/Note/FormatLogViewController.swift @@ -40,6 +40,7 @@ class FormatLogViewController: UIViewController { formatButton.backgroundColor = .systemBlue formatButton.setTitleColor(.white, for: .normal) formatButton.layer.cornerRadius = 12 + formatButton.addTarget(self, action: #selector(didTapFormatButton), for: .touchUpInside) view.addSubview(formatButton) NSLayoutConstraint.activate([ @@ -58,6 +59,32 @@ class FormatLogViewController: UIViewController { @objc private func didTapDoneButton() { textView.resignFirstResponder() } + + @objc private func didTapFormatButton() { + textView.text = formatLog(textView.text) + } + + private func formatLog(_ text: String) -> String { + var content = text + + content = content.replacingOccurrences(of: "# ", with: "") + content = content.replacingOccurrences(of: "#", with: "") + content = content.replacingOccurrences(of: ";", with: "。") + content = content.replacingOccurrences(of: ";", with: "。") + content = content.replacingOccurrences(of: ".", with: "。") + content = content.replacingOccurrences(of: "(", with: "(") + content = content.replacingOccurrences(of: ")", with: ")") + content = content.replacingOccurrences(of: "?", with: "?") + content = content.replacingOccurrences(of: ",", with: ",") + content = content.replacingOccurrences(of: ":", with: ":") + content = content.replacingOccurrences(of: "日星期", with: "日 星期") + content = "# " + content + content = content.replacingOccurrences(of: "一、生活方面", with: "## 一、生活方面") + content = content.replacingOccurrences(of: "二、交易方面", with: "## 二、交易方面") + content = content.replacingOccurrences(of: "三、工作方面", with: "## 三、工作方面") + + return content + } } extension FormatLogViewController: UITextViewDelegate {