Hugo Module
for HTML inline tags missing in Goldmark
Replacement codes let us avoid raw HTML in Markdown.
A single partial replaces them with the inline tags
lacking a syntax element in Goldmark.
The codes look like {*text}
, where *
is a placeholder for one or more ASCII characters. The superscript tag <sup>
for example is marked by ^
and fits the following regular expression (Golang syntax):
replaceRE `\{\^([^}]*)\}` "<sup>$1</sup>"
This syntax does not collide with any other elements — as far as I know. And it’s safe because the replacements are applied after the Markdown rendering. Hugo discards all HTML in Markdown by default and also checks these codes before the regular expressions are applied.
All replacements are chained together in one Hugo partial, which can process every piece of rendered Markdown content in the templates.
These replacements are published as a tiny Hugo module on GitHub.
This approach is a workaround. To create extensions for Hugo’s Markdown renderer Goldmark would be the better solution.