diff --git a/content/contribute/components/code-blocks.md b/content/contribute/components/code-blocks.md index ee4b135318..8a1abdccc0 100644 --- a/content/contribute/components/code-blocks.md +++ b/content/contribute/components/code-blocks.md @@ -8,6 +8,18 @@ Rouge provides lots of different code block "hints". If you leave off the hint, it tries to guess and sometimes gets it wrong. These are just a few hints that we use often. +## Variables + +If your example contains a placeholder value that's subject to change, +use the format `<[A-Z_]+>` for the placeholder value: `` + +```none +export name= +``` + +This syntax is reserved for variable names, and will cause the variable to +be rendered in a special color and font style. + ## Bash Use the `bash` language code block when you want to show a Bash script: @@ -157,4 +169,4 @@ authorizedkeys: - AUTHORIZED_KEYS=ssh-rsa AAAAB3Nsomelongsshkeystringhereu9UzQbVKy9o00NqXa5jkmZ9Yd0BJBjFmb3WwUR8sJWZVTPFL volumes: /root:/user:rw -``` \ No newline at end of file +``` diff --git a/layouts/_default/_markup/render-codeblock.html b/layouts/_default/_markup/render-codeblock.html index 75709aab44..2fa0fa14f1 100644 --- a/layouts/_default/_markup/render-codeblock.html +++ b/layouts/_default/_markup/render-codeblock.html @@ -1,13 +1,22 @@ -
+{{ $innerHTML := highlight .Inner .Type +| replaceRE + `<([A-Z_]+)?>` + `$1` +}} + +
- {{ highlight .Inner .Type }} +
+ {{- safeHTML $innerHTML -}} +