From 3a11e3e7e70348e40f27d49e6ba7989591313f5d Mon Sep 17 00:00:00 2001 From: squidfunk Date: Wed, 19 Feb 2025 09:06:38 +0700 Subject: [PATCH] Fixed tags plugin not working on filenames with whitespaces --- material/plugins/tags/structure/listing/manager/__init__.py | 4 ++++ src/plugins/tags/structure/listing/manager/__init__.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/material/plugins/tags/structure/listing/manager/__init__.py b/material/plugins/tags/structure/listing/manager/__init__.py index a22958862e9..1a235a29240 100644 --- a/material/plugins/tags/structure/listing/manager/__init__.py +++ b/material/plugins/tags/structure/listing/manager/__init__.py @@ -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 diff --git a/src/plugins/tags/structure/listing/manager/__init__.py b/src/plugins/tags/structure/listing/manager/__init__.py index a22958862e9..1a235a29240 100644 --- a/src/plugins/tags/structure/listing/manager/__init__.py +++ b/src/plugins/tags/structure/listing/manager/__init__.py @@ -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