恢复iCloud格式化原始逻辑

This commit is contained in:
2026-07-12 22:38:44 +08:00
parent 8d117f7f97
commit e01404f18e
+11 -22
View File
@@ -208,30 +208,19 @@ class FormatNoteViewController: UIViewController {
content = content.replacingOccurrences(of: old, with: new) 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: "日 星期") 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 = "# " + content
content = insertEmptyLineAfterFirstLine(content)
return content return content
} }