Add clearWhenEmpty option to markText

Stop doing this automatically for marks inclusive on both
sides.

Issue #1996
Fix infinite recursion in lineIsHiddenInner for stacked spans

Closes #1996