Text processing utilities¶
-
coaster.utils.text.
compress_whitespace
(text)[source]¶ Reduce all space-like characters into single spaces and strip from ends.
-
coaster.utils.text.
normalize_spaces
(text)[source]¶ Replace whitespace characters with regular spaces.
-
coaster.utils.text.
normalize_spaces_multiline
(text)[source]¶ Replace whitespace characters with regular spaces, in multiline text.
Line break characters like newlines are not considered whitespace.
-
coaster.utils.text.
sanitize_html
(value, valid_tags=None, strip=True, linkify=False)[source]¶ Strip unwanted markup out of HTML.
-
coaster.utils.text.
simplify_text
(text)[source]¶ Simplify text to allow comparison.
>>> simplify_text("Awesome Coder wanted at Awesome Company") 'awesome coder wanted at awesome company' >>> simplify_text("Awesome Coder, wanted at Awesome Company! ") 'awesome coder wanted at awesome company' >>> simplify_text("Awesome Coder, wanted at Awesome Company! ") == ( ... 'awesome coder wanted at awesome company') True
-
coaster.utils.text.
text_blocks
(html_text, skip_pre=True)[source]¶ Extracts a list of paragraphs from a given HTML string.
-
coaster.utils.text.
ulstrip
(text)[source]¶ Strip Unicode extended whitespace from the left side of a string.