diff --git a/src/overrides/hooks/translations.py b/src/overrides/hooks/translations.py index 33a83ef22..882d51488 100644 --- a/src/overrides/hooks/translations.py +++ b/src/overrides/hooks/translations.py @@ -124,7 +124,7 @@ def on_page_markdown(markdown: str, *, page: Page, config: MkDocsConfig, files): # ----------------------------------------------------------------------------- # Map ISO 639-1 (languages) to ISO 3166 (countries) -countries = dict({ +countries = { "af": "za", "az": "az", "ar": "ae", @@ -191,4 +191,4 @@ countries = dict({ "zh": "cn", "zh-Hant": "cn", "zh-TW": "tw" -}) +} diff --git a/src/plugins/privacy/config.py b/src/plugins/privacy/config.py index b5b6c29c3..de983b4fe 100644 --- a/src/plugins/privacy/config.py +++ b/src/plugins/privacy/config.py @@ -21,7 +21,7 @@ import os from mkdocs.config.base import Config -from mkdocs.config.config_options import Deprecated, DictOfItems, Type +from mkdocs.config.config_options import DictOfItems, Type # ----------------------------------------------------------------------------- # Classes diff --git a/src/plugins/privacy/plugin.py b/src/plugins/privacy/plugin.py index 5a4eefe77..779c67511 100644 --- a/src/plugins/privacy/plugin.py +++ b/src/plugins/privacy/plugin.py @@ -62,11 +62,11 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]): # Initialize collections of external assets self.assets = Files([]) - self.assets_expr_map = dict({ + self.assets_expr_map = { ".css": r"url\((\s*http?[^)]+)\)", ".js": r"[\"'](http[^\"']+\.(?:css|js(?:on)?))[\"']", **self.config.assets_expr_map - }) + } # Process external style sheets and scripts (run latest) - run this after # all other plugins, so they can add additional assets @@ -537,7 +537,7 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]): log = logging.getLogger("mkdocs.material.privacy") # Expected file extensions -extensions = dict({ +extensions = { "application/javascript": ".js", "image/avif": ".avif", "image/gif": ".gif", @@ -547,4 +547,4 @@ extensions = dict({ "image/webp": ".webp", "text/javascript": ".js", "text/css": ".css" -}) +} diff --git a/src/plugins/search/plugin.py b/src/plugins/search/plugin.py index 724de6e0a..22cd6d215 100644 --- a/src/plugins/search/plugin.py +++ b/src/plugins/search/plugin.py @@ -450,16 +450,15 @@ class Parser(HTMLParser): return # Render opening tag if kept - if not self.skip.intersection(self.context): - if tag in self.keep: + if not self.skip.intersection(self.context) and tag in self.keep: - # Check whether we're inside the section title - data = self.section.text - if self.section.el in self.context: - data = self.section.title + # Check whether we're inside the section title + data = self.section.text + if self.section.el in self.context: + data = self.section.title - # Append to section title or text - data.append(f"<{tag}>") + # Append to section title or text + data.append(f"<{tag}>") # Called at the end of every HTML tag def handle_endtag(self, tag): @@ -488,29 +487,28 @@ class Parser(HTMLParser): return # Render closing tag if kept - if not self.skip.intersection(self.context): - if tag in self.keep: + if not self.skip.intersection(self.context) and tag in self.keep: - # Check whether we're inside the section title - data = self.section.text - if self.section.el in self.context: - data = self.section.title + # Check whether we're inside the section title + data = self.section.text + if self.section.el in self.context: + data = self.section.title - # Search for corresponding opening tag - index = data.index(f"<{tag}>") - for i in range(index + 1, len(data)): - if not data[i].isspace(): - index = len(data) - break + # Search for corresponding opening tag + index = data.index(f"<{tag}>") + for i in range(index + 1, len(data)): + if not data[i].isspace(): + index = len(data) + break - # Remove element if empty (or only whitespace) - if len(data) > index: - while len(data) > index: - data.pop() + # Remove element if empty (or only whitespace) + if len(data) > index: + while len(data) > index: + data.pop() - # Append to section title or text - else: - data.append(f"") + # Append to section title or text + else: + data.append(f"") # Called for the text contents of each tag def handle_data(self, data): diff --git a/src/plugins/social/plugin.py b/src/plugins/social/plugin.py index 3cdfa3ce2..c6ed29be4 100644 --- a/src/plugins/social/plugin.py +++ b/src/plugins/social/plugin.py @@ -491,7 +491,7 @@ log = logging.getLogger("mkdocs") log.addFilter(DuplicateFilter()) # Color palette -colors = dict({ +colors = { "red": { "fill": "#ef5552", "text": "#ffffff" }, "pink": { "fill": "#e92063", "text": "#ffffff" }, "purple": { "fill": "#ab47bd", "text": "#ffffff" }, @@ -513,4 +513,4 @@ colors = dict({ "blue-grey": { "fill": "#546d78", "text": "#ffffff" }, "black": { "fill": "#000000", "text": "#ffffff" }, "white": { "fill": "#ffffff", "text": "#000000" } -}) +} diff --git a/src/plugins/tags/config.py b/src/plugins/tags/config.py index f2d950845..2d388c268 100644 --- a/src/plugins/tags/config.py +++ b/src/plugins/tags/config.py @@ -18,12 +18,9 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. -from functools import partial -from markdown.extensions.toc import slugify from mkdocs.config.config_options import Optional, Type from mkdocs.config.base import Config -from . import casefold # ----------------------------------------------------------------------------- # Classes