diff options
author | David Lord <davidism@gmail.com> | 2020-01-28 20:16:59 -0800 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2020-02-05 08:44:15 -0800 |
commit | 2a8515d2e53a2be475d9df3fe44e308501201a95 (patch) | |
tree | 88c9e788ce0e0be96b27e0e40f82e7c406567ee3 /docs/api.rst | |
parent | 42edc132902562e1e16f190bea60362865da894f (diff) | |
download | jinja-2a8515d2e53a2be475d9df3fe44e308501201a95.tar.gz |
apply pyupgrade and f-strings
Diffstat (limited to 'docs/api.rst')
-rw-r--r-- | docs/api.rst | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/docs/api.rst b/docs/api.rst index 501a2c6d..075bcc6a 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -675,12 +675,14 @@ enabled:: import re from jinja2 import evalcontextfilter, Markup, escape - _paragraph_re = re.compile(r'(?:\r\n|\r(?!\n)|\n){2,}') + _paragraph_re = re.compile(r"(?:\r\n|\r(?!\n)|\n){2,}") @evalcontextfilter def nl2br(eval_ctx, value): - result = u'\n\n'.join(u'<p>%s</p>' % p.replace('\n', Markup('<br>\n')) - for p in _paragraph_re.split(escape(value))) + result = "\n\n".join( + f"<p>{p.replace('\n', Markup('<br>\n'))}</p>" + for p in _paragraph_re.split(escape(value)) + ) if eval_ctx.autoescape: result = Markup(result) return result |