Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 7, 2024
1 parent b6830a0 commit a79a4ee
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/sphinx_tags/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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"""
Expand All @@ -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.
Expand Down

0 comments on commit a79a4ee

Please sign in to comment.