恢复iCloud格式化原始逻辑
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user