Skip to content

Commit 3a11e3e

Browse files
committed
Fixed tags plugin not working on filenames with whitespaces
1 parent 2752b9e commit 3a11e3e

File tree

2 files changed

+8
-0
lines changed
  • material/plugins/tags/structure/listing/manager
  • src/plugins/tags/structure/listing/manager

2 files changed

+8
-0
lines changed

material/plugins/tags/structure/listing/manager/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ def replace(match: Match) -> str:
176176
# is unique, so we use the page source file path and the position
177177
# of the match within the page as an identifier.
178178
id = f"{page.file.src_uri}:{match.start()}-{match.end()}"
179+
180+
# Replace whitespaces in the identifier that we computed, or we
181+
# can't just prefix it with "#" - see https://t.ly/U_hfp
182+
id = id.replace(" ", "-")
179183
self.data.add(Listing(page, id, config))
180184

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

src/plugins/tags/structure/listing/manager/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ def replace(match: Match) -> str:
176176
# is unique, so we use the page source file path and the position
177177
# of the match within the page as an identifier.
178178
id = f"{page.file.src_uri}:{match.start()}-{match.end()}"
179+
180+
# Replace whitespaces in the identifier that we computed, or we
181+
# can't just prefix it with "#" - see https://t.ly/U_hfp
182+
id = id.replace(" ", "-")
179183
self.data.add(Listing(page, id, config))
180184

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

0 commit comments

Comments
 (0)