Skip to content

Commit

Permalink
Fixed tags plugin not working on filenames with whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Feb 19, 2025
1 parent 2752b9e commit 3a11e3e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions material/plugins/tags/structure/listing/manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ def replace(match: Match) -> str:
# is unique, so we use the page source file path and the position
# of the match within the page as an identifier.
id = f"{page.file.src_uri}:{match.start()}-{match.end()}"

# Replace whitespaces in the identifier that we computed, or we
# can't just prefix it with "#" - see https://t.ly/U_hfp
id = id.replace(" ", "-")
self.data.add(Listing(page, id, config))

# Replace directive with hx headline if listings are enabled, or
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/tags/structure/listing/manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ def replace(match: Match) -> str:
# is unique, so we use the page source file path and the position
# of the match within the page as an identifier.
id = f"{page.file.src_uri}:{match.start()}-{match.end()}"

# Replace whitespaces in the identifier that we computed, or we
# can't just prefix it with "#" - see https://t.ly/U_hfp
id = id.replace(" ", "-")
self.data.add(Listing(page, id, config))

# Replace directive with hx headline if listings are enabled, or
Expand Down

0 comments on commit 3a11e3e

Please sign in to comment.