mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-16 17:55:13 +00:00
Resolve escaped characters in a status (#2071)
* Resolve escaped characters in a status Escaped characters are now returned to their original form for HTMLString.asRawText. * Unescape the markdown version too The HTMLString.asMarkdown string is now also unescaped, & and similar are resolved. * Fix a internal fallback If one of the unescape(...) commands fails, the original, unescaped text is used instead of an empty string.
This commit is contained in:
parent
6ed760a775
commit
7caf00d07d
1 changed files with 4 additions and 2 deletions
|
@ -61,7 +61,7 @@ public struct HTMLString: Codable, Equatable, Hashable, @unchecked Sendable {
|
|||
_ = text.removeLast()
|
||||
_ = text.removeLast()
|
||||
}
|
||||
asRawText = text
|
||||
asRawText = (try? Entities.unescape(text)) ?? text
|
||||
|
||||
if asMarkdown.hasPrefix("\n") {
|
||||
_ = asMarkdown.removeFirst()
|
||||
|
@ -175,7 +175,9 @@ public struct HTMLString: Codable, Equatable, Hashable, @unchecked Sendable {
|
|||
return
|
||||
} else if node.nodeName() == "#text" {
|
||||
var txt = node.description
|
||||
|
||||
|
||||
txt = (try? Entities.unescape(txt)) ?? txt
|
||||
|
||||
if let underscore_regex, let main_regex {
|
||||
// This is the markdown escaper
|
||||
txt = main_regex.stringByReplacingMatches(in: txt, options: [], range: NSRange(location: 0, length: txt.count), withTemplate: "\\\\$1")
|
||||
|
|
Loading…
Reference in a new issue