The syntax is simple: The targeted piece of text is enclosed by the curly braces { and } and an ASCII sign after the first one. x{‍^3} for example gets turned into x3.

Quick Overview

Perplex includes the following replacement codes and styles them:

Line Breaka{‍/}ba

These codes are substituted with the help of short regular expressions in the layout template replacements.html. It processes the Hugo variable .Content which contains the rendered Markdown content as HTML string. The procedure is safe, because Goldmark treats the curly braces and their content like any other Markdown and discards raw HTML to prevent script attacks. Should you enable raw HTML, security is not your concern anyway.

Available as a module

The template file for the theme has a separated repository hugo-mod-replacements.

To manipulate our generated HTML with regular expressions isn’t bad, because its secure and fast. But it’s a syntax hack and can’t be parsed the usual way. There are relatively common syntax extensions for most of these elements which other Markdown renderers have already implemented. Extensions for Goldmark which could be enabled in Hugo, would be the better solution. Then we could run a regex parser for the last time on these replacements and turn them into extended Markdown syntax.