Background
I lacked motivation to keep this tweaked theme up with Hugo’s development after last summer. When I came back yesterday, I saw that some pages using Font Awesome icons were broken. Apart from that, the ToC list level problem resurfaced.
Fixed ToC
The solution that I had adopted no longer worked. Luckily, some users provided a shorter code in the later discussions. The one from user501254 caught me. I first tried to copy his code into the partial layout for ToC. However, nothing changed.
{{ $emtLiPtrn := "(?s)<ul>\\s<li>\\s<ul>(.*)</li>\\s</ul>" }}
{{ $rplcEmtLi := "<ul>$1" }}
{{ .TableOfContents | replaceRE $emtLiPtrn $rplcEmtLi | safeHTML }}
In an attempt to identify the cause of this error, I looked for the official
docs for replaceRE
, whose syntax seemed to be unchanged. I then
played with the PATTERN
and REPLACEMENT
with some simple syntax—that
worked. This showed that the problem was about $emtLiPtrn
. Thanks to
https://regex101.com/ and the generated HTML source code, I found that appending
an asterisk *
after each \\s
in $emtLiPtrn
fixed the issue.
<aside class="toc-article">
<nav id="TableOfContents">
<ul>
<li>
<ul>
<li><a href="#for-each-ref">for-each-ref</a></li>
<li><a href="#ls-files-ls-tree">ls-files, ls-tree</a></li>
<li><a href="#merge-base">merge-base</a></li>
<li><a href="#merge---squash-rebase--i">merge –squash, rebase -i</a></li>
<li><a href="#reflog">reflog</a></li>
<li><a href="#rev-parse">rev-parse</a></li>
<li><a href="#diff">diff</a></li>
</ul>
</li>
</ul>
</nav>
</aside>
This fix is available online at commit a3d7343a on GitLab.
Remarks: In the linked regex testing website, the “golang” favour has to be
chosen, and use \s
instead of \\s
.
Fixed missing Font Awesome icons
In the page for Math.SE comment templates, the text areas
disappeared. Inspecting the elements, the message <!-- raw HTML omitted -->
popped up. Thanks to this Japanese article, I quickly solved this
problem at commit 74c81df0 on GitLab.