X7ROOT File Manager
Current Path:
/lib/python2.7/site-packages/pip/_vendor/html5lib/filters
lib
/
python2.7
/
site-packages
/
pip
/
_vendor
/
html5lib
/
filters
/
??
..
??
__init__.py
(0 B)
??
__init__.pyc
(160 B)
??
__init__.pyo
(160 B)
??
alphabeticalattributes.py
(621 B)
??
alphabeticalattributes.pyc
(1.36 KB)
??
alphabeticalattributes.pyo
(1.36 KB)
??
base.py
(286 B)
??
base.pyc
(1.08 KB)
??
base.pyo
(1.08 KB)
??
inject_meta_charset.py
(2.68 KB)
??
inject_meta_charset.pyc
(2.2 KB)
??
inject_meta_charset.pyo
(2.2 KB)
??
lint.py
(3.29 KB)
??
lint.pyc
(2.96 KB)
??
lint.pyo
(2.06 KB)
??
optionaltags.py
(10.29 KB)
??
optionaltags.pyc
(4.3 KB)
??
optionaltags.pyo
(4.3 KB)
??
sanitizer.py
(24.52 KB)
??
sanitizer.pyc
(25.17 KB)
??
sanitizer.pyo
(25.05 KB)
??
whitespace.py
(1.11 KB)
??
whitespace.pyc
(1.62 KB)
??
whitespace.pyo
(1.62 KB)
Editing: whitespace.py
from __future__ import absolute_import, division, unicode_literals import re from . import base from ..constants import rcdataElements, spaceCharacters spaceCharacters = "".join(spaceCharacters) SPACES_REGEX = re.compile("[%s]+" % spaceCharacters) class Filter(base.Filter): spacePreserveElements = frozenset(["pre", "textarea"] + list(rcdataElements)) def __iter__(self): preserve = 0 for token in base.Filter.__iter__(self): type = token["type"] if type == "StartTag" \ and (preserve or token["name"] in self.spacePreserveElements): preserve += 1 elif type == "EndTag" and preserve: preserve -= 1 elif not preserve and type == "SpaceCharacters" and token["data"]: # Test on token["data"] above to not introduce spaces where there were not token["data"] = " " elif not preserve and type == "Characters": token["data"] = collapse_spaces(token["data"]) yield token def collapse_spaces(text): return SPACES_REGEX.sub(' ', text)
Upload File
Create Folder