mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Remove extra new line before list items and useless paragraph style
This commit is contained in:
committed by
Stefan Ceriu
parent
f33d29b7e9
commit
a1038f0ffe
@@ -207,9 +207,6 @@ struct AttributedStringBuilderV2: AttributedStringBuilderProtocol {
|
||||
case "ul", "ol":
|
||||
var listIndex = 1
|
||||
content = attributedString(element: childElement, documentBody: documentBody, preserveFormatting: preserveFormatting, listTag: tag, listIndex: &listIndex, indentLevel: indentLevel + 1)
|
||||
if listTag == nil { // If not within another list
|
||||
content.insert(NSAttributedString(string: "\n"), at: 0)
|
||||
}
|
||||
|
||||
case "li":
|
||||
var bullet = ""
|
||||
@@ -224,11 +221,6 @@ struct AttributedStringBuilderV2: AttributedStringBuilderProtocol {
|
||||
content.insert(NSAttributedString(string: bullet), at: 0)
|
||||
content.append(NSAttributedString(string: "\n"))
|
||||
|
||||
let paragraphStyle = NSMutableParagraphStyle()
|
||||
paragraphStyle.headIndent = CGFloat(indentLevel) * 20
|
||||
paragraphStyle.firstLineHeadIndent = CGFloat(indentLevel) * 20
|
||||
content.addAttribute(.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: content.length))
|
||||
|
||||
case "img":
|
||||
if let alt = try? childElement.attr("alt"), !alt.isEmpty {
|
||||
content = NSMutableAttributedString(string: "[img: \(alt)]")
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c5597aa7bd2475300acdbf32ff6bc5c0781ef773a4ccc9f50c93fed3f4d67378
|
||||
size 1112093
|
||||
oid sha256:92079b7c81266f0d7fd47b97673dbac31a8c6781661dc520396ef7adcfdcdf85
|
||||
size 1111292
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c5597aa7bd2475300acdbf32ff6bc5c0781ef773a4ccc9f50c93fed3f4d67378
|
||||
size 1112093
|
||||
oid sha256:92079b7c81266f0d7fd47b97673dbac31a8c6781661dc520396ef7adcfdcdf85
|
||||
size 1111292
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c1ea06e567eb4549250863c7318003620a852d1144a993fd692500554c53bdb7
|
||||
size 1266526
|
||||
oid sha256:2d0942967dab15b03dc50f23be248cb23fee0d3c4baea535f71884af01fe54a6
|
||||
size 1264950
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c1ea06e567eb4549250863c7318003620a852d1144a993fd692500554c53bdb7
|
||||
size 1266526
|
||||
oid sha256:2d0942967dab15b03dc50f23be248cb23fee0d3c4baea535f71884af01fe54a6
|
||||
size 1264950
|
||||
|
||||
@@ -738,6 +738,21 @@ class AttributedStringBuilderV1Tests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
func testListTags() {
|
||||
let htmlString = "<p>like</p>\n<ul>\n<li>this<br />\ntest</li>\n</ul>\n"
|
||||
|
||||
guard let attributedString = attributedStringBuilder.fromHTML(htmlString) else {
|
||||
XCTFail("Could not build the attributed string")
|
||||
return
|
||||
}
|
||||
|
||||
if AttributedStringBuilder.useNextGenHTMLParser {
|
||||
XCTAssertEqual(String(attributedString.characters), "like\n\n • this\ntest")
|
||||
} else {
|
||||
XCTAssertEqual(String(attributedString.characters), "like\n\t•\tthis\u{2028}test")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Phishing prevention
|
||||
|
||||
func testPhishingLink() {
|
||||
|
||||
Reference in New Issue
Block a user