Skip to content

don't include text from sanitised elements? #33

Open
@AntiSol

Description

@AntiSol

Hi, thanks for html_sanitizer, I've been using it for a while and it's been doing a great job.

I was wondering if there's a way to have html_sanitizer not include the text from elements that it strips out. For example, given:

<badtag>bad text</badtag>
<p>good text</p>

I would like to have html-sanitizer return <p>good text</p>, but at the moment I get back bad text<p>good text</p>

I looked into doing this with an element_preprocessor, I was thinking I could simply set the text to an empty string if the tag wasn't in the list of allowed tags, but it seems that elements which aren't in the allow list don't make it into the preprocessors, e.g the preprocessor never fires for the element because the sanitizer is stripping that tag before it gets to that stage.

Any suggestions would be appreciated! :)

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