Skip to content

Commit

Permalink
Merge branch 'develop' into issue/289-multiple-headings
Browse files Browse the repository at this point in the history
  • Loading branch information
hypest committed Mar 17, 2017
2 parents 6c7e8ac + c8bbee9 commit a30168b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ class HeadingHandler : BlockHandler<AztecHeadingSpan>(AztecHeadingSpan::class.ja
}

override fun handleEndOfBufferMarker() {
// adjust the block end to only include the chars before the end-of-text marker. A newline will be there.
if (block.start == markerIndex) {
// ok, this list item has the marker as its first char so, nothing more to do here.
return
}

// the heading has bled over to the marker so, let's adjust its range to just before the marker.
// There's a newline there hopefully :)
block.end = markerIndex
}

Expand Down
16 changes: 14 additions & 2 deletions aztec/src/test/kotlin/org/wordpress/aztec/HeadingTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,19 @@ class HeadingTest() {
Assert.assertEquals("<h1 foo=\"bar\">Heading 1unstyled</h1>", editText.toHtml())
}

@Test
@Throws(Exception::class)
fun deleteHeadingChars_Issue287() {
editText.fromHtml("<h1>he</h1>")

var l = safeLength(editText)
editText.text.delete(l - 1, l)

l = safeLength(editText)
editText.text.delete(l - 1, l)
Assert.assertEquals("<h1></h1>", editText.toHtml())
}

@Test
@Throws(Exception::class)
fun addHeading_issue289() {
Expand All @@ -249,5 +262,4 @@ class HeadingTest() {
safeAppend(editText, "Heading 2")
Assert.assertEquals("<h1>Heading 1</h1><h2>Heading 2</h2>", editText.toHtml())
}

}
}

0 comments on commit a30168b

Please sign in to comment.