diff --git a/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift b/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift index bcaa0f44b..b3f56cda7 100644 --- a/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift +++ b/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift @@ -185,7 +185,7 @@ nonisolated struct AttributedStringBuilder: AttributedStringBuilderProtocol { content = attributedString(element: childElement, documentBody: documentBody, preserveFormatting: preserveFormatting, listTag: listTag, listIndex: &childIndex, indentLevel: indentLevel) content.addAttribute(.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: NSRange(location: 0, length: content.length)) - case "s", "del": + case "s", "del", "strike": content = attributedString(element: childElement, documentBody: documentBody, preserveFormatting: preserveFormatting, listTag: listTag, listIndex: &childIndex, indentLevel: indentLevel) content.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.single.rawValue, range: NSRange(location: 0, length: content.length)) diff --git a/UnitTests/Sources/AttributedStringBuilderTests.swift b/UnitTests/Sources/AttributedStringBuilderTests.swift index a215c8d39..67dd16c23 100644 --- a/UnitTests/Sources/AttributedStringBuilderTests.swift +++ b/UnitTests/Sources/AttributedStringBuilderTests.swift @@ -673,6 +673,17 @@ struct AttributedStringBuilderTests { #expect(String(attributedString.characters) == "one two") } + @Test + func strikethroughTags() throws { + var strikethrough = AttributedString("one") + strikethrough[AttributeScopes.UIKitAttributes.StrikethroughStyleAttribute.self] = .single + + for tag in ["s", "del", "strike"] { + let attributedString = try #require(attributedStringBuilder.fromHTML("<\(tag)>one\(tag)>"), "Could not build the attributed string") + #expect(attributedString == strikethrough, "<\(tag)> should render as a strikethrough") + } + } + @Test func unorderedList() throws { let htmlString = "