Hi! I’m trying to make a Hugo theme, and I wanted to include an icon library to go with it. I really like this one, Material Icons by the Pictogrammers, so I included it in my theme.
For ease of use, I’m trying to implement a custom Markdown Syntax to use icons. Right now, you have to type <i class="mdi mdi-link"></i>
to use an icon for example, but I want users to be able to write : link :, and for the icon to render. (I had to leave a space between the word and the colon if not it will turn into an emoji, but I do not want any spacing)
I’ve tried the following with layouts/_defaults/_markup/render-string.html
, but it dosn’t work, and just outputs the text, not actually turning it into an icon:
{{- $pattern := `:(\w+):` -}}
{{- $replacement := `<i class="mdi mdi-$1"></i>` -}}
{{- $processedContent := . | replaceRE $pattern $replacement | safeHTML -}}
{{- return $processedContent -}}
Any suggestions as to how to do this would be much appreciated. Thank you!