fix: [BUG] # character accumulation in markdown frontmatter tags prop (#79)

This commit is contained in:
github-actions[bot]
2025-04-05 23:07:53 -05:00
committed by GitHub
parent 9bff1f732e
commit 6c19c9edf5
3 changed files with 62 additions and 3 deletions
+10 -2
View File
@@ -138,15 +138,23 @@ def parse_tags(tags: Union[List[str], str, None]) -> List[str]:
Returns:
A list of tag strings, or an empty list if no tags
Note:
This function strips leading '#' characters from tags to prevent
their accumulation when tags are processed multiple times.
"""
if tags is None:
return []
# Process list of tags
if isinstance(tags, list):
return tags
# First strip whitespace, then strip leading '#' characters to prevent accumulation
return [tag.strip().lstrip('#') for tag in tags if tag and tag.strip()]
# Process comma-separated string of tags
if isinstance(tags, str):
return [tag.strip() for tag in tags.split(",") if tag.strip()]
# Split by comma, strip whitespace, then strip leading '#' characters
return [tag.strip().lstrip('#') for tag in tags.split(",") if tag and tag.strip()]
# For any other type, try to convert to string and parse
try: # pragma: no cover