Skip to content

Commit 5f30471

Browse files
committed
Allow jumping to anchors with MediaWiki-style underscores
Hugo turns whitespace in headers into "-", whereas MediaWiki converts whitespace to "_". Generate a second id to cover both.
1 parent b0c2664 commit 5f30471

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!-- .Anchor will turn whitespace in header names to "-", but mediawiki uses "_". Attach a second id with "-" changed to "_" here to make both work. -->
2+
<span id="{{ replace (.Anchor | safeURL) "-" "_" }}">
3+
<h{{ .Level }} id="{{ .Anchor | safeURL }}">
4+
{{ .Text | safeHTML }}
5+
<a class="anchor" href="#{{ .Anchor | safeURL }}">#</a>
6+
</h{{ .Level }}>
7+
</span>

0 commit comments

Comments
 (0)