Markwon icon indicating copy to clipboard operation
Markwon copied to clipboard

Last paragraph has weird bottom margin

Open wojcikrafal opened this issue 9 months ago • 0 comments

  • Markwon version: 4.6.2

Using the HTML plugin when rendering mutliple paragraphs the las one has additional bottom margin. I'd expect to have all paragraphs have same margins.

class MarkwonActivity : Activity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val markwon = Markwon.builder(this)
            .usePlugin(HtmlPlugin.create())
            .build()

        val html = """
            <p>First paragraph</p>
            <p>Second paragraph</p>
            """.trimIndent()

        setContentView(LinearLayout(this).apply {
            orientation = LinearLayout.VERTICAL
            addView(TextView(this@MarkwonActivity).apply {
                text = markwon.toMarkdown(html)
                setTextColor(Color.BLACK)
                setBackgroundColor(Color.RED)
            })
        })
    }
}

Given this sample I get the following results:

image

If I change the HTML to

val html = """
    <p>First paragraph</p>
    <b>Second paragraph</b>        
    """.trimIndent()

Then it looks like I wanted it to

image

I wouldn't mind this behavior but if add more spacing between paragraphs (via the LastLineSpacingSpan) I'll end up with doubled bottom spacing for the last paragraph.

wojcikrafal avatar May 24 '24 12:05 wojcikrafal