Skip to content

Commit

Permalink
tryfix: temporary fix for #201 by removing deep quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
fsy2001 committed Jul 4, 2024
1 parent a3fad60 commit bc5010b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion DanXiUI/Forum/Presentation/FloorPresentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ struct FloorPresentation: Identifiable {
init(floor: Floor, storey: Int, floors: [Floor] = []) {
self.floor = floor
self.storey = storey
self.sections = parseFloorContent(content: floor.content, mentions: floor.mentions, floors: floors)
// self.sections = parseFloorContent(content: floor.content, mentions: floor.mentions, floors: floors)
self.sections = parseFloorContent(content: temporaryFixForContentOverflow(floor.content), mentions: floor.mentions, floors: floors)
self.replyTo = parseFirstMention(content: floor.content)
self.imageURLs = parseFloorImageURLs(content: floor.content)
}
Expand Down Expand Up @@ -35,6 +36,19 @@ func convertInlineImages(content: String) -> String {
return modifiedContent
}

/// This is a temporary fix for issue #201 by removing deep quotes
func temporaryFixForContentOverflow(_ content: String) -> String {
let pattern = "^(>){4,}"
guard let regex = try? NSRegularExpression(pattern: pattern, options: []) else {
return content
}
let lines = content.components(separatedBy: .newlines)
let processedLines = lines.map { line -> String in
return regex.stringByReplacingMatches(in: line, options: [], range: NSRange(location: 0, length: line.utf16.count), withTemplate: ">>>")
}
return processedLines.joined(separator: "\n")
}

func parseFloorContent(content: String, mentions: [Mention], floors: [Floor]) -> [FloorSection] {
var partialContent = convertInlineImages(content: content)
var sections: [FloorSection] = []
Expand Down

0 comments on commit bc5010b

Please sign in to comment.