Skip to content

Commit 85f00d7

Browse files
committed
Fix issue with newlines being created as tags in .ipynb files
1 parent fe09bce commit 85f00d7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/sphinx_tags/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def __init__(self, entrypath: Path):
278278

279279
self.tags = []
280280
if tagblock:
281-
self.tags = [_normalize_display_tag(tag) for tag in tagblock if tag != ""]
281+
self.tags = [_normalize_display_tag(tag) for tag in tagblock if tag]
282282

283283
def assign_to_tags(self, tag_dict):
284284
"""Append ourself to tags"""
@@ -309,7 +309,8 @@ def _normalize_display_tag(tag: str) -> str:
309309
310310
Example: ' Tag:with (extra whitespace) ' -> 'Tag:with (extra whitespace)'
311311
"""
312-
return re.sub(r"\s+", " ", tag.strip('"').strip())
312+
tag = tag.replace("\\n", "\n").strip('"').strip()
313+
return re.sub(r"\s+", " ", tag)
313314

314315

315316
def tagpage(tags, outdir, title, extension, tags_index_head):

0 commit comments

Comments
 (0)