This fixes a regression in commit 60293416db that
changed the `__hash__` implementation of Node from the default pointer
hash, to a hash based on the node fields.
Since these fields contains list objects, they are not hashable, making
every call to `Node.__hash__` fail.
This breaks some third-party usage such as in `django-compressor`
(See: https://github.com/django-compressor/django-compressor/issues/1060)
This changed reverts the hash method back to using `object.__hash__` as
the hash implementation.
Python str.splitlines() splits by more characters[1], which, however,
causes problems when keeping these special characters in processed
templates is desirable, i.e. these bug reports: #769, #952, #1313.
The keep_trailing_newlines logic is reworked because splitlines()
removes them already (so they had to be added), while re.split doesn't
so they have to be removed.
[1] https://docs.python.org/3/library/stdtypes.html#str.splitlines
Allow indention with generic characters, e.g. Tabs.
Implemenented the behavior requested in
https://github.com/pallets/jinja/pull/1167#issuecomment-612644701
The width param can be string or int, if it is string it's the raw
indention e.g. "\t". If it's int it's the number of spaces. In other
cases an FilterArgumentError is raised, to avoid confusion.
This required allowing tests to be decorated with '@environmentfilter'.
Tests are essentially the same as filters now, the node, compiler, and
environment have been refactored to extract common behavior.
don't try other url types if one already matched
no-op function if trim is not enabled
avoid backtracking when matching trailing punctuation
match head and tail punctuation separately
don't scan for unbalanced parentheses more than necessary
ensure email domain starts and ends with a word character
If there is only single node and it is not a string, there is no point
in passing it into ``literal_eval``, just return it immediately.
One of the examples where passing a non-string node into
``literal_eval`` would actually cause problems is when the node is
``Undefined``. On Python 3.10 this would cause ``UndefinedError``
instead of just ``Undefined`` being returned.
Fixes#1335