Function | conditional_escape |
Similar to escape(), except that it doesn't operate on pre-escaped strings. |
Function | escape |
Return the given text with ampersands, quotes and angle brackets encoded for use in HTML. |
Function | format_html |
Similar to str.format, but pass all arguments through conditional_escape(), and call mark_safe() on the result. This function should be used instead of str.format or % interpolation to build up small HTML fragments. |
Function | format_html_join |
A wrapper of format_html, for the common case of a group of arguments that need to be formatted using the same format string, and then joined using 'sep'. 'sep' is also passed through conditional_escape. |
Function | html_safe |
A decorator that defines the __html__ method. This helps non-Django templates to detect classes whose __str__ methods return SafeString. |
Function | strip_tags |
Return the given HTML with all tags stripped. |
Constant | DOTS |
Undocumented |
Constant | TRAILING_PUNCTUATION_CHARS |
Undocumented |
Constant | WRAPPING_PUNCTUATION |
Undocumented |
Variable | simple_url_2_re |
Undocumented |
Variable | simple_url_re |
Undocumented |
Variable | word_split_re |
Undocumented |
Class | MLStripper |
Undocumented |
Function | _strip_once |
Internal tag stripping utility used by strip_tags. |
Function | avoid_wrapping |
Avoid text wrapping in the middle of a phrase by adding non-breaking spaces where there previously were normal spaces. |
Function | escapejs |
Hex encode characters for use in JavaScript strings. |
Function | json_script |
Escape all the HTML/XML special characters with their unicode escapes, so value is safe to be output anywhere except for inside a tag attribute. Wrap the escaped JSON in a script tag. |
Function | linebreaks |
Convert newlines into <p> and <br>s. |
Function | smart_urlquote |
Quote a URL if it isn't already quoted. |
Function | strip_spaces_between_tags |
Return the given HTML with spaces between tags removed. |
Function | urlize |
Convert any URLs in text into clickable links. |
Variable | _js_escapes |
Undocumented |
Variable | _json_script_escapes |
Undocumented |
Similar to escape(), except that it doesn't operate on pre-escaped strings.
This function relies on the __html__ convention used both by Django's SafeData class and by third-party libraries like markupsafe.
Return the given text with ampersands, quotes and angle brackets encoded for use in HTML.
Always escape input, even if it's already escaped and marked as such. This may result in double-escaping. If this is a concern, use conditional_escape() instead.
A wrapper of format_html, for the common case of a group of arguments that need to be formatted using the same format string, and then joined using 'sep'. 'sep' is also passed through conditional_escape.
'args_generator' should be an iterator that returns the sequence of 'args' that will be passed to format_html.
Example:
format_html_join('
Convert any URLs in text into clickable links.
Works on http://, https://, www. links, and also on links ending in one of the original seven gTLDs (.com, .edu, .gov, .int, .mil, .net, and .org). Links can have trailing punctuation (periods, commas, close-parens) and leading punctuation (opening parens) and it'll still do the right thing.
If trim_url_limit is not None, truncate the URLs in the link text longer than this limit to trim_url_limit - 1 characters and append an ellipsis.
If nofollow is True, give the links a rel="nofollow" attribute.
If autoescape is True, autoescape the link text and URLs.