diff --git a/Sources/HTMLStreamer/AttributedStringConverter.swift b/Sources/HTMLStreamer/AttributedStringConverter.swift index a4d2436..528291a 100644 --- a/Sources/HTMLStreamer/AttributedStringConverter.swift +++ b/Sources/HTMLStreamer/AttributedStringConverter.swift @@ -135,7 +135,7 @@ public struct AttributedStringConverter { finishRun() styleStack.append(.unorderedList) case "li": - if str.length != 0 || !currentRun.isEmpty { + if !currentRun.isEmpty { currentRun.append("\n") } let marker: String diff --git a/Tests/HTMLStreamerTests/AttributedStringConverterTests.swift b/Tests/HTMLStreamerTests/AttributedStringConverterTests.swift index 2c5147d..1821e3e 100644 --- a/Tests/HTMLStreamerTests/AttributedStringConverterTests.swift +++ b/Tests/HTMLStreamerTests/AttributedStringConverterTests.swift @@ -319,4 +319,19 @@ final class AttributedStringConverterTests: XCTestCase { XCTAssertEqual(convert("

inside
quote
after

"), 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("

a

  1. b
"), result) + } + }