Fix extra line breaks being inserted before lists
This commit is contained in:
parent
a32b972201
commit
74baa2912f
|
@ -135,7 +135,7 @@ public struct AttributedStringConverter<Callbacks: HTMLConversionCallbacks> {
|
||||||
finishRun()
|
finishRun()
|
||||||
styleStack.append(.unorderedList)
|
styleStack.append(.unorderedList)
|
||||||
case "li":
|
case "li":
|
||||||
if str.length != 0 || !currentRun.isEmpty {
|
if !currentRun.isEmpty {
|
||||||
currentRun.append("\n")
|
currentRun.append("\n")
|
||||||
}
|
}
|
||||||
let marker: String
|
let marker: String
|
||||||
|
|
|
@ -319,4 +319,19 @@ final class AttributedStringConverterTests: XCTestCase {
|
||||||
XCTAssertEqual(convert("<p></p><blockquote><span>inside<br>quote</span></blockquote><span>after</span><p></p>"), result)
|
XCTAssertEqual(convert("<p></p><blockquote><span>inside<br>quote</span></blockquote><span>after</span><p></p>"), result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testParagraphFollowedByList() {
|
||||||
|
let result = NSMutableAttributedString()
|
||||||
|
result.append(NSAttributedString(string: "a\n\n", attributes: [
|
||||||
|
.font: font,
|
||||||
|
.paragraphStyle: NSParagraphStyle.default,
|
||||||
|
.foregroundColor: color,
|
||||||
|
]))
|
||||||
|
result.append(NSAttributedString(string: "\t1.\tb", attributes: [
|
||||||
|
.font: font,
|
||||||
|
.paragraphStyle: listParagraphStyle,
|
||||||
|
.foregroundColor: color,
|
||||||
|
]))
|
||||||
|
XCTAssertEqual(convert("<p>a</p><ol><li>b</li></ol>"), result)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue