From 5bec964e81d9342ce92b838ad235247dec670f51 Mon Sep 17 00:00:00 2001 From: Laurent Franceschetti Date: Sun, 28 Jul 2024 09:03:16 +0200 Subject: [PATCH] Add standard filter `normalize_url` (#236) - This filter is imported from mkdocs.utils --- mkdocs_macros/context.py | 13 ++++++++++--- setup.py | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mkdocs_macros/context.py b/mkdocs_macros/context.py index 62418f6..15bc7b6 100644 --- a/mkdocs_macros/context.py +++ b/mkdocs_macros/context.py @@ -9,8 +9,6 @@ Laurent Franceschetti (c) 2020 """ from urllib.parse import urlparse -from mkdocs.structure.nav import get_navigation -from mkdocs.structure.files import File import os import sys import subprocess @@ -22,6 +20,9 @@ from functools import partial import mkdocs +from mkdocs.structure.nav import get_navigation +from mkdocs.structure.files import File +from mkdocs.utils import normalize_url import jinja2 from jinja2 import Template from markdown import markdown @@ -56,7 +57,7 @@ def list_items(obj): return enumerate(list(obj)) -def get_first_para(s): +def get_first_para(s) -> str: "Get the first para of a docstring" first_lines = [] for row in s.strip().splitlines(): @@ -377,3 +378,9 @@ def now(): # add fix url function as macro env.macro(fix_url) + + + + + # add the normal mkdocs url function + env.filter(normalize_url) \ No newline at end of file diff --git a/setup.py b/setup.py index 0ceb7b5..e17626f 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ # Initialization # -------------------- -VERSION_NUMBER = '1.1.1' +VERSION_NUMBER = '1.1.2' # required if you want to run document/test # pip install 'mkdocs-macros-plugin[test]'