{{ $url := (printf "%s#%s" .Page.Permalink .Anchor) | safeURL }}
<h{{ .Level }} id="{{ .Anchor | safeURL }}">
{{ .Text | safeHTML }}
<a class="heading-anchor" href="{{ $url }}" style="color: var(--text-muted); font-size: smaller;">
{{ "#" }}
</a>
</h{{ .Level }}>