From 2d642b3863d5a2e04c2c9464f015405d93370b3a Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Fri, 25 Mar 2022 19:45:19 +0100 Subject: [PATCH 1/2] Compatibility with Jinja2 3.1.0 (#2800) --- mkdocs/utils/filters.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mkdocs/utils/filters.py b/mkdocs/utils/filters.py index e7fb163e..9644f0c3 100644 --- a/mkdocs/utils/filters.py +++ b/mkdocs/utils/filters.py @@ -1,8 +1,12 @@ import json -import jinja2 import markupsafe +try: + from jinja2 import pass_context as contextfilter +except ImportError: + from jinja2 import contextfilter + from mkdocs.utils import normalize_url @@ -10,7 +14,7 @@ def tojson(obj, **kwargs): return markupsafe.Markup(json.dumps(obj, **kwargs)) -@jinja2.contextfilter +@contextfilter def url_filter(context, value): """ A Template filter to normalize URLs. """ return normalize_url(value, page=context['page'], base=context['base_url']) From 6c1eb589f472c9bf3360e5687c3a40002c7ac804 Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Sat, 26 Mar 2022 20:33:54 +0100 Subject: [PATCH 2/2] Release 1.2.4 (#2805) --- docs/about/release-notes.md | 7 +++++++ mkdocs/__init__.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/about/release-notes.md b/docs/about/release-notes.md index 64aee9f6..ace2048e 100644 --- a/docs/about/release-notes.md +++ b/docs/about/release-notes.md @@ -21,6 +21,13 @@ The current and past members of the MkDocs team. * [@d0ugal](https://github.com/d0ugal/) * [@waylan](https://github.com/waylan/) +## Version 1.2.4 (2022-03-26) + +* Compatibility with Jinja2 3.1.0 (#2800) + + Due to a breaking change in Jinja2, MkDocs would crash with the message + `AttributeError: module 'jinja2' has no attribute 'contextfilter'` + ## Version 1.2.3 (2021-10-12) * Built-in themes now also support these languages: diff --git a/mkdocs/__init__.py b/mkdocs/__init__.py index 69760b06..33d2a7af 100644 --- a/mkdocs/__init__.py +++ b/mkdocs/__init__.py @@ -2,4 +2,4 @@ # For acceptable version formats, see https://www.python.org/dev/peps/pep-0440/ -__version__ = '1.2.3' +__version__ = '1.2.4'