How to use replacements
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:
Element | Code | Result | Since Hugo 126.0 |
---|---|---|---|
Superscript | {^3} | 3 | deprecated |
Subscript | {_2} | 2 | deprecated |
Keyboard | {~K} | K | |
Variable | {$variable} | variable | |
Mark | {!mark} | mark | deprecated |
Citation | {=work} | work | |
Insertion | {+insert} | insert | deprecated |
Conditional break | a{/}b | a b | |
Optional word break | long{w}word | long |
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.