File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ extension String {
99 ///
1010 /// - Returns: `true` if the specified index is in an empty line, `false` otherwise.
1111 ///
12- func isEmptyLine( at index: String . Index ) -> Bool {
12+ public func isEmptyLine( at index: String . Index ) -> Bool {
1313 return isStartOfNewLine ( at: index) && isEndOfLine ( at: index)
1414 }
1515
@@ -20,7 +20,7 @@ extension String {
2020 ///
2121 /// - Returns: `true` if the specified offset is in an empty line, `false` otherwise.
2222 ///
23- func isEmptyLine( at offset: Int ) -> Bool {
23+ public func isEmptyLine( at offset: Int ) -> Bool {
2424 guard let index = self . indexFromLocation ( offset) else {
2525 return true
2626 }
Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ public class ElementNode: Node {
136136
137137 override func needsClosingParagraphSeparator( ) -> Bool {
138138 return ( !hasChildren( ) )
139- && ( hasAttributes ( ) || !isLastInTree( ) )
139+ && ( canBeLastInTree ( ) || !isLastInTree( ) )
140140 && ( isBlockLevel ( ) || hasRightBlockLevelSibling ( ) || isLastInAncestorEndingInBlockLevelSeparation ( ) )
141141 }
142142
@@ -258,6 +258,14 @@ public class ElementNode: Node {
258258 return false
259259 }
260260
261+ /// Check if the node can be the last one in a tree
262+ ///
263+ /// - Returns: Returns `true` if it can be the last one, false otherwise.
264+ ///
265+ func canBeLastInTree( ) -> Bool {
266+ return hasAttributes ( ) || type == . li
267+ }
268+
261269 /// Find out if this is a block-level element.
262270 ///
263271 /// - Returns: `true` if this is a block-level element. `false` otherwise.
Original file line number Diff line number Diff line change @@ -1980,4 +1980,13 @@ class TextViewTests: XCTestCase {
19801980
19811981 XCTAssertEqual ( output, expected)
19821982 }
1983+
1984+ /// This test makes sure that if an empty list is in the original HTML, it will still get output after our processing.
1985+ func testEmptyListsPersistsAfterAztec( ) {
1986+ let textView = TextViewStub ( withHTML: " <ul><li></li></ul> " )
1987+
1988+ let html = textView. getHTML ( prettify: false )
1989+
1990+ XCTAssertEqual ( html, " <ul><li></li></ul> " )
1991+ }
19831992}
You can’t perform that action at this time.
0 commit comments