slackware-current/source/l/python-typogrify/jinja-3.1.patch
Patrick J Volkerding d39761cf9b Sat Nov 25 19:44:38 UTC 2023
a/shadow-4.14.2-x86_64-2.txz:  Rebuilt.
  adduser: fixed chown syntax to silence warnings. Thanks to Stuart Winter.
l/gi-docgen-2023.3-x86_64-1.txz:  Added.
  Thanks to Heinz Wiesinger.
l/python-smartypants-2.0.1-x86_64-1.txz:  Added.
  Needed for gi-docgen. Thanks to Heinz Wiesinger.
l/python-toml-0.10.2-x86_64-1.txz:  Added.
  Needed for gi-docgen. Thanks to Heinz Wiesinger.
l/python-typogrify-2.0.7-x86_64-1.txz:  Added.
  Needed for gi-docgen. Thanks to Heinz Wiesinger.
x/xdg-desktop-portal-1.18.2-x86_64-1.txz:  Upgraded.
  Thanks to 0XBF.
testing/packages/php-8.3.0-x86_64-1.txz:  Added.
2023-11-25 20:59:35 +01:00

45 lines
1.5 KiB
Diff

From 34b6e01b71afd6876bbd2ef7ad134d11d05c82a0 Mon Sep 17 00:00:00 2001
From: Jordan Yelloz <jordan@yelloz.me>
Date: Sat, 2 Apr 2022 11:29:31 -0600
Subject: [PATCH] jinja_filters: Updated import for Jinja 3.1.
Added some fallback imports just to reduce the possibility of breakage with
users running the latest version of typogrify and older versions of Flask/Jinja
for whatever reason.
Jinja 3.1.x has removed the jinja2.Markup function which was deprecated in Jinja
3.0.x.
See:
- https://jinja.palletsprojects.com/en/3.1.x/changes/#version-3-1-0
- https://github.com/pallets/jinja/pull/1544
(cherry picked from commit 279c6b6c9f3a8b1bd065960a0e0bbe73236d717f)
---
typogrify/templatetags/jinja_filters.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/typogrify/templatetags/jinja_filters.py b/typogrify/templatetags/jinja_filters.py
index 0596c0b..d6e9b9e 100644
--- a/typogrify/templatetags/jinja_filters.py
+++ b/typogrify/templatetags/jinja_filters.py
@@ -1,6 +1,9 @@
from typogrify.filters import amp, caps, initial_quotes, smartypants, titlecase, typogrify, widont, TypogrifyError
from functools import wraps
-import jinja2
+try:
+ from markupsafe import Markup
+except ImportError:
+ from jinja2 import Markup
from jinja2.exceptions import TemplateError
@@ -18,7 +21,7 @@ def make_safe(f):
out = f(text)
except TypogrifyError as e:
raise TemplateError(e.message)
- return jinja2.Markup(out)
+ return Markup(out)
wrapper.is_safe = True
return wrapper