Markwon icon indicating copy to clipboard operation
Markwon copied to clipboard

How to remove underline while using h1 tag in redme ?

Open Groot-2001 opened this issue 2 years ago • 2 comments

i am using h1 tag in readme section and at the end of the title an underline is appear, how should i get rid of that underline?

Groot-2001 avatar May 28 '22 13:05 Groot-2001

same issue, how to remove underline for H1 and H2 ?

tatavarthitarun avatar Jun 06 '22 11:06 tatavarthitarun

Tried this?

private class NoSpecialTreatmentOfH1H2Plugin : AbstractMarkwonPlugin() {
    override fun configureSpansFactory(builder: MarkwonSpansFactory.Builder) {
        builder.setFactory(Heading::class.java) { configuration, props ->
            HeadingSpanModified(
                configuration.theme(),
                CoreProps.HEADING_LEVEL.require(props)
            )
        }
    }
}
private class HeadingSpanModified(theme: MarkwonTheme, range: Int) : HeadingSpan(theme, range) {
    override fun drawLeadingMargin(
        c: Canvas?,
        p: Paint?,
        x: Int,
        dir: Int,
        top: Int,
        baseline: Int,
        bottom: Int,
        text: CharSequence?,
        start: Int,
        end: Int,
        first: Boolean,
        layout: Layout?
    ) {
        // NO-OP
    }
}

And creating Markwon by:

val markwon = Markwon.builder(context).usePlugin(NoSpecialTreatmentOfH1H2Plugin()).build()

c-b-h avatar Oct 09 '22 14:10 c-b-h

Hello @Groot-2001, @tatavarthitarun , @c-b-h ,

there is a heading theme attribute you can use:

val markwon = Markwon.builder(context)
  .usePlugin(object: AbstractMarkwonPlugin() {
    override fun configureTheme(builder: MarkwonTheme.Builder) {
      builder.headingBreakHeight(0)
    }
  })
  .build()

noties avatar Dec 09 '22 01:12 noties