mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Add support for the <strike> tag in the attributed string builder
This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
@@ -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 = "<ul><li>1</li><li>2</li><li>3</li></ul>"
|
||||
|
||||
Reference in New Issue
Block a user