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
_get_default_module takes an optional context to indicate that the
template is imported. If there are differences between the environment
and rendered template globals, a new module is used for the imported
template.