Skip to content
This repository has been archived by the owner on Jan 8, 2022. It is now read-only.

Cleaning is not configurable enough #2

Open
mjl opened this issue Jun 21, 2012 · 2 comments
Open

Cleaning is not configurable enough #2

mjl opened this issue Jun 21, 2012 · 2 comments

Comments

@mjl
Copy link

mjl commented Jun 21, 2012

The set of allowed tags and merge tags is hardcoded and cannot be changed.

Ideally, one would like to be able to set those once as default or per cleanse call.

@sbaechler
Copy link
Contributor

The class based approach is a good start. It still needs a hook for custom cleaner functions.

The # remove elements containing only whitespace or linebreaks function must be configurable as well. Because now it also cleans empty <td></td> tags which invalidates tables. And sometimes <p></p> is ok.

@l-monnier
Copy link

You can actually edit the list of allowed tags by changing the value of the class attribute.
For example, if you wish to add some extra tags for a particular instance::

additional_allowed_tags = {
    'h1':(),
    'h4':(),
    'h5':(),
    'h6':(),
    'i':(),
    'div':(),
}
cleanse = Cleanse()
cleanse.allowed_tags.update(additional_allowed_tags)

Note that since it is a class attribute, you can also edit the value of the class (so all future instances will have the new value)::

additional_allowed_tags = {
    'h1':(),
    'h4':(),
    'h5':(),
    'h6':(),
    'i':(),
    'div':(),
}
Cleanse.allowed_tags.update(additional_allowed_tags)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants