Upgrade to Python 3.9

I also needed to patch my Jinja2 filters to not use a deprecated method
of declaring themselves, since the upgrade pulled in a newer minor
version of Jinja2.

The upgrade also tried to pull in Django 4, which many of the plugins
I'm using can't cope with yet, so it needed to be convinced not to do
that.
This commit is contained in:
Danielle McLean 2022-04-29 14:54:49 +10:00
parent db0d6e28a3
commit d4c814c79a
Signed by untrusted user: 00dani
GPG key ID: 52C059C3B22A753E
4 changed files with 310 additions and 335 deletions

View file

@ -1,6 +1,7 @@
from bleach.sanitizer import Cleaner, ALLOWED_TAGS
from bleach.linkifier import LinkifyFilter
from jinja2 import evalcontextfilter, Markup
from jinja2 import pass_eval_context
from markupsafe import Markup
TAGS = ['cite', 'code', 'details', 'p', 'pre', 'img', 'span', 'summary']
TAGS.extend(ALLOWED_TAGS)
@ -14,7 +15,7 @@ ATTRIBUTES = {
cleaner = Cleaner(tags=TAGS, attributes=ATTRIBUTES, filters=(LinkifyFilter,))
@evalcontextfilter
@pass_eval_context
def bleach(ctx, html):
res = cleaner.clean(html)
if ctx.autoescape:

View file

@ -1,4 +1,4 @@
from jinja2 import evalcontextfilter
from jinja2 import pass_eval_context
from markdown import Markdown
from .bleach import bleach
@ -11,6 +11,6 @@ md = Markdown(extensions=(
))
@evalcontextfilter
@pass_eval_context
def markdown(ctx, source):
return bleach(ctx, md.reset().convert(source))