Text enclosed by curly braces { and } and special ASCII signs is replaced with missing Markdown tags after rendering.

Quick Overview

Perplex includes the following replacement codes and styles them:

ElementCodeResult
Superscript{‍^3}3
Subscript{‍_2}2
Keyboard{‍~K}K
Variable{‍$variable}variable
Mark{‍!mark}mark
Citation{‍=work}work
Insertion{‍+insert}insert
Conditional breaka{‍/}ba 
b
Optional word breaklong{‍w}wordlongword

These codes are substituted with the help of short regular expressions in the layout template replacements.html. It processes the Hugo variable .Content that contains the rendered Markdown as an HTML string.

The substitutions are safe because Goldmark checks these codes like any other Markdown and discards any raw HTML before they are replaced.

Available as a module

The replacement template is available in a separate repository: hugo-mod-replacements.

These substitutions are reliable but a hack. The codes can’t be parsed by Markdown renderers. A better solution would be to add extensions for Goldmark and for many elements there already is a relatively common syntax in other Markdown flavors. If they would be available for Goldmark, we could run a regex parser for the last time on these replacements and change them into regular extended syntax.