Site Maintenance for Hugo v0.60

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.

Hugo 

3 comments

Anon's gravatar

Anon

Hi Vincent,

I am using your staticman system and bot on a website for my class. Recently, some students are complaining that they receive the message “Sorry, there was an error with your submission. Please make sure all required fields have been completed and try again.” when posting (the dev console shows a 500 Internal Server Error from https://staticman3.herokuapp.com/v3/entry/***/***.gitlab.io/master with the XHR response showing MISSING_PARAMS as errorCode. This is only happening from certain IP addresses. In there any chance that these IP addresses are being blocked by your heroku server?

As a test, I tried posting a comment on this website from one of these IP addresses and got the same error.

Thanks.

Your email address will not be published. Required fields are marked *.