迁移格式化逻辑到 iOS 端并删除 Python 脚本
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user