File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
aztec/src/main/kotlin/org/wordpress/aztec Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -133,7 +133,11 @@ class AztecParser(val plugins: List<IAztecPlugin> = ArrayList()) {
133133 val parent = IAztecNestable .getParent(spanned, SpanWrapper (spanned, it))
134134
135135 // a list item "repels" a child list so the list will appear in the next line
136- val repelling = it is AztecListSpan && parent?.span is AztecListItemSpan
136+ val parentListItem = spanned.getSpans(spanned.getSpanStart(it), spanned.getSpanEnd(it), AztecListItemSpan ::class .java)
137+ .filter { item -> item.nestingLevel < it.nestingLevel }
138+ .sortedBy { item -> item.nestingLevel }
139+ .firstOrNull()
140+ val repelling = it is AztecListSpan && parentListItem != null
137141
138142 val spanStart = spanned.getSpanStart(it)
139143 val spanEnd = spanned.getSpanEnd(it)
@@ -160,6 +164,10 @@ class AztecParser(val plugins: List<IAztecPlugin> = ArrayList()) {
160164 return @forEach
161165 }
162166
167+ if (repelling && spanStart > 0 && spanned[spanStart - 1 ] == ' \n ' && spanStart - 1 >= spanned.getSpanStart(parentListItem)) {
168+ return @forEach
169+ }
170+
163171 // well, it seems we need a visual newline so, add one and mark it as such
164172 spanned.insert(spanStart, " \n " )
165173
You can’t perform that action at this time.
0 commit comments