python-docutils for man pages, the rest for API docs, though that also needs introspection, and we don't have any of that yet.
46 lines
1.5 KiB
Diff
46 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
|
|
|