All Downloads are FREE. Search and download functionalities are using the official Maven repository.

name.remal.gradle_plugins.dsl.utils.htmlToText.kt Maven / Gradle / Ivy

package name.remal.gradle_plugins.dsl.utils

import net.htmlparser.jericho.Source
import java.lang.Math.min

fun htmlToText(html: String, maxLength: Int = 98): String = Source(html).renderer
    .setMaxLineLength(maxLength)
    .setHRLineLength(min(maxLength, 40))
    .setConvertNonBreakingSpaces(true)
    .setIncludeFirstElementTopMargin(false)
    .setIncludeHyperlinkURLs(true)
    .setIncludeAlternateText(true)
    .setNewLine("\n")
    .setBlockIndentSize(2)
    .setListIndentSize(2)
    .setTableCellSeparator(" | ")
    .toString()
    .trim('\n')




© 2015 - 2024 Weber Informatics LLC | Privacy Policy