Skip to content

Commit

Permalink
Fix issue with newlines being created as tags in .ipynb files
Browse files Browse the repository at this point in the history
  • Loading branch information
JWCook committed Jul 7, 2024
1 parent fe09bce commit 85f00d7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/sphinx_tags/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def __init__(self, entrypath: Path):

self.tags = []
if tagblock:
self.tags = [_normalize_display_tag(tag) for tag in tagblock if tag != ""]
self.tags = [_normalize_display_tag(tag) for tag in tagblock if tag]

def assign_to_tags(self, tag_dict):
"""Append ourself to tags"""
Expand Down Expand Up @@ -309,7 +309,8 @@ def _normalize_display_tag(tag: str) -> str:
Example: ' Tag:with (extra whitespace) ' -> 'Tag:with (extra whitespace)'
"""
return re.sub(r"\s+", " ", tag.strip('"').strip())
tag = tag.replace("\\n", "\n").strip('"').strip()
return re.sub(r"\s+", " ", tag)


def tagpage(tags, outdir, title, extension, tags_index_head):
Expand Down

0 comments on commit 85f00d7

Please sign in to comment.