From 90be0603da56ffbb79c10ad7f378891e19e98daf Mon Sep 17 00:00:00 2001 From: Mathias Rav Date: Sat, 30 Jun 2018 12:10:33 +0200 Subject: [PATCH] Wikilinks: Use new config API Accept **kwargs in __init__() instead of a `configs` sequence. Also inherit from Extension directly since nothing in Markdown's WikilinksExtension is used (and to avoid Markdown's extension overriding the config in django-wiki's extension). --- src/wiki/plugins/macros/mdx/wikilinks.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/wiki/plugins/macros/mdx/wikilinks.py b/src/wiki/plugins/macros/mdx/wikilinks.py index 41b6b1c1..6ca05156 100644 --- a/src/wiki/plugins/macros/mdx/wikilinks.py +++ b/src/wiki/plugins/macros/mdx/wikilinks.py @@ -5,7 +5,7 @@ import re import markdown from django.urls import reverse -from markdown.extensions import wikilinks +from markdown.extensions import Extension, wikilinks def build_url(label, base, end, md): @@ -22,9 +22,9 @@ def build_url(label, base, end, md): return '%s%s%s' % (base, clean_label, end) -class WikiLinkExtension(wikilinks.WikiLinkExtension): +class WikiLinkExtension(Extension): - def __init__(self, configs={}): + def __init__(self, **kwargs): # set extension defaults self.config = { 'base_url': ['', 'String to append to beginning or URL.'], @@ -32,10 +32,7 @@ class WikiLinkExtension(wikilinks.WikiLinkExtension): 'html_class': ['wiki_wikilink', 'CSS hook. Leave blank for none.'], 'build_url': [build_url, 'Callable formats URL from label.'], } - - # Override defaults with user settings - for key, value in configs: - self.setConfig(key, value) + super().__init__(**kwargs) def extendMarkdown(self, md, md_globals): self.md = md -- 2.45.2