From a79a4ee50ec1665dad2afbe9ae1f82f8119060e3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 7 Jul 2024 18:24:32 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/sphinx_tags/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/sphinx_tags/__init__.py b/src/sphinx_tags/__init__.py index 0b1388c..9f6f479 100644 --- a/src/sphinx_tags/__init__.py +++ b/src/sphinx_tags/__init__.py @@ -66,7 +66,10 @@ def run(self): # self.content: StringList(['different, tags,', 'separated'], # items=[(path, lineno), (path, lineno)]) page_tags.extend( - [_normalize_display_tag(tag) for tag in ",".join(self.content).split(",")] + [ + _normalize_display_tag(tag) + for tag in ",".join(self.content).split(",") + ] ) # Remove empty elements from page_tags # (can happen after _normalize_tag()) @@ -274,7 +277,9 @@ def __init__(self, entrypath: Path): self.tags = [] if tagblock: - self.tags = [_normalize_display_tag(tag).rstrip('"') for tag in tagblock if tag != ""] + self.tags = [ + _normalize_display_tag(tag).rstrip('"') for tag in tagblock if tag != "" + ] def assign_to_tags(self, tag_dict): """Append ourself to tags""" @@ -299,12 +304,14 @@ def _normalize_tag(tag: str, dashes: bool = False) -> str: char = "-" return re.sub(r"[\s\W]+", char, tag).lower().strip(char) + def _normalize_display_tag(tag: str) -> str: """Strip extra whitespace from a tag name for display purposes. Example: ' Tag:with (extra whitespace) ' -> 'Tag:with (extra whitespace)' """ - return re.sub(r"\s+", ' ', tag.strip()) + return re.sub(r"\s+", " ", tag.strip()) + def tagpage(tags, outdir, title, extension, tags_index_head): """Creates Tag overview page.