Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 885 Bytes

README.md

File metadata and controls

40 lines (30 loc) · 885 Bytes

htmlReplace

License

HTML tag replacement tool for Kotlin (Java).

Required dependencies:

Example usage:

import kotlinx.html.*

htmlReplace(
    html = """
        <p>Allo, <q>Mars</q></p>
    """.trimIndent(),

    cssQuery = ":containsOwn(Mars)" to {
        a {
            href = "https://www.mars.com"
            unsafe {
                raw(it.outerHtml())
            }
        }
    }
)

Output:

<p>Allo, <a href="https://mars.com"><q>Mars</q></a></p>

How to use:

  • define cssQuery using JSoup syntax;
  • (optional) access original element properties: it.attributes(), it.html().