Fix ascii shrug guy

Changelog-Fixed: Fix ascii shrug guy
Closes: #238
This commit is contained in:
Lionello Lunesu
2023-01-03 23:05:41 -08:00
committed by William Casarin
parent 39fa973a80
commit e9380c3821
3 changed files with 14 additions and 3 deletions

View File

@@ -20,7 +20,9 @@ public struct Markdown {
let md_opts: AttributedString.MarkdownParsingOptions =
.init(interpretedSyntax: .inlineOnlyPreservingWhitespace)
if let txt = try? AttributedString(markdown: content, options: md_opts) {
// TODO: escape unintentional markdown
let escaped = content.replacingOccurrences(of: "\\_", with: "\\\\\\_")
if let txt = try? AttributedString(markdown: escaped, options: md_opts) {
return txt
} else {
return AttributedString(stringLiteral: content)
@@ -40,7 +42,6 @@ public struct Markdown {
let uri = url.scheme == "http" ? Markdown.withScheme(text) : url.absoluteString
output.replaceSubrange(range, with: "[\(text)](\(uri))")
}
// TODO: escape unintentional markdown
return Markdown.parse(content: output)
}
}