diff options
author | Christian Pedersen <chripede@gmail.com> | 2015-11-19 14:21:36 +0100 |
---|---|---|
committer | Christian Pedersen <chripede@gmail.com> | 2015-11-19 14:21:36 +0100 |
commit | 12b93e23e8447a03ab592b30406ae85406d150c3 (patch) | |
tree | 028e4f1dcc4f5546dcaf54edccc702256a01199c | |
parent | 5c408df92e8445f50ad51a37306d547e601822cf (diff) | |
download | python-lxml-12b93e23e8447a03ab592b30406ae85406d150c3.tar.gz |
Add inline_style option
Currently the style option will remove both style tags and attributes.
This change makes each an option, just like scripts and javascript.
-rw-r--r-- | src/lxml/html/clean.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lxml/html/clean.py b/src/lxml/html/clean.py index 99fe42b1..47a32749 100644 --- a/src/lxml/html/clean.py +++ b/src/lxml/html/clean.py @@ -112,7 +112,10 @@ class Cleaner(object): Removes any comments. ``style``: - Removes any style tags or attributes. + Removes any style tags. + + ``inline_style`` + Removes any style attributes. ``links``: Removes any ``<link>`` tags @@ -191,6 +194,7 @@ class Cleaner(object): javascript = True comments = True style = False + inline_style = False links = True meta = True page_structure = True @@ -314,6 +318,7 @@ class Cleaner(object): kill_tags.add(etree.ProcessingInstruction) if self.style: kill_tags.add('style') + if self.inline_style: etree.strip_attributes(doc, 'style') if self.links: kill_tags.add('link') |