Skip to content

Commit 189ac57

Browse files
committed
Remove HTML from descriptions
1 parent 73b7a9e commit 189ac57

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

BrickHack-Mobile/Models/ScheduleParser.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ class ScheduleParser {
276276
case 1: currentEvent.time = stringToDate(cellText) ?? Date()
277277
case 2: currentEvent.title = cellText
278278
case 3: currentEvent.location = cellText
279-
case 4: currentEvent.description = cellText
279+
case 4: currentEvent.description = filterDescription(cellText)
280280
case 5: currentEvent.uuid = cellText
281281
default: break
282282
}
@@ -286,6 +286,21 @@ class ScheduleParser {
286286

287287
}
288288

289+
// Strips the description of any HTML
290+
private static func filterDescription(_ text: String) -> String {
291+
292+
var result = String(text)
293+
294+
while result.contains("<") && result.contains(">") {
295+
let htmlStart = result.firstIndex(of: "<")!
296+
let htmlEnd = result.firstIndex(of: ">")!
297+
298+
result.removeSubrange(htmlStart...htmlEnd)
299+
}
300+
301+
print("Converted \(text) to \(result)")
302+
return result
303+
}
289304

290305
private static func stringToDate(_ text: String) -> Date? {
291306

0 commit comments

Comments
 (0)