Skip to content

[Feature] Extension Modules #11

Description

@MFlisar

What do you think of adding support for custom tag handlers that can support custom styling like:

// per htmlToAnnotatedString
htmlToAnnotatedString(
        html,
        renderers = listOf<TagRenderer>(...) // list if custom tag handlers
    )

// or globally
HTMLConverterCompose.registerRenderers(listOf<TagRenderer>(....))

where each handler get the tag name, the attributes and the text and returns an AnnotatedString, something like e.g.

interface TagRenderer {
    fun handles(tag: String, attributes: List<String>): Boolean // function to decide if this renderer can handle a tag
    fun render(tag: String, attributes: List<String>, text: String): AnnotatedString // function to actually convert the tag to an AnnotatedString
}

Idee

I could write my own extensions or you could even provide modules like a color span renderer like e.g. <span style="color:blue"> (that's what I want to have) and similar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions