Add unescape param to code shortcode
This commit is contained in:
@@ -431,7 +431,8 @@ The `paige/code` shortcode provides highlighted code.
|
|||||||
```
|
```
|
||||||
{{< paige/code
|
{{< paige/code
|
||||||
lang=""
|
lang=""
|
||||||
options="" >}}
|
options=""
|
||||||
|
unescape=false >}}
|
||||||
|
|
||||||
{{< /paige/code >}}
|
{{< /paige/code >}}
|
||||||
```
|
```
|
||||||
@@ -443,6 +444,8 @@ Parameters:
|
|||||||
<dd>Optional. Position 0. String. Chroma <a href="https://gohugo.io/content-management/syntax-highlighting/#list-of-chroma-highlighting-languages">language code</a>. Default is <code>plaintext</code>.</dd>
|
<dd>Optional. Position 0. String. Chroma <a href="https://gohugo.io/content-management/syntax-highlighting/#list-of-chroma-highlighting-languages">language code</a>. Default is <code>plaintext</code>.</dd>
|
||||||
<dt><code>options</code></dt>
|
<dt><code>options</code></dt>
|
||||||
<dd>Optional. String. Hugo <a href="https://gohugo.io/content-management/syntax-highlighting/#highlight-shortcode">highlight options</a>.</dd>
|
<dd>Optional. String. Hugo <a href="https://gohugo.io/content-management/syntax-highlighting/#highlight-shortcode">highlight options</a>.</dd>
|
||||||
|
<dt><code>unescape</code></dt>
|
||||||
|
<dd>Optional. Boolean. Whether to reverse the HTML escaping in the body. Useful for when the request shortcode is used in the body.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
Body: Required. String. The code.
|
Body: Required. String. The code.
|
||||||
|
@@ -167,6 +167,38 @@ float Q_rsqrt( float number )
|
|||||||
}
|
}
|
||||||
{{< /paige/code >}}
|
{{< /paige/code >}}
|
||||||
|
|
||||||
|
## Unescape parameter
|
||||||
|
|
||||||
|
Code:
|
||||||
|
|
||||||
|
```go-html-template
|
||||||
|
{{</* paige/code unescape=false */>}}
|
||||||
|
{{</* paige/request "[...]" */>}}
|
||||||
|
{{</* /paige/code */>}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
{{< paige/code unescape=false >}}
|
||||||
|
{{< paige/request "https://gist.githubusercontent.com/willfaught/fe6f6a8b9715e70112b6894935ecbecd/raw/64f41b7eb47ed5a60172217f8ba3868c23f69d21/qrsqrt.c" >}}
|
||||||
|
{{< /paige/code >}}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Code:
|
||||||
|
|
||||||
|
```go-html-template
|
||||||
|
{{</* paige/code unescape=true */>}}
|
||||||
|
{{</* paige/request "[...]" */>}}
|
||||||
|
{{</* /paige/code */>}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
{{< paige/code unescape=true >}}
|
||||||
|
{{< paige/request "https://gist.githubusercontent.com/willfaught/fe6f6a8b9715e70112b6894935ecbecd/raw/64f41b7eb47ed5a60172217f8ba3868c23f69d21/qrsqrt.c" >}}
|
||||||
|
{{< /paige/code >}}
|
||||||
|
|
||||||
## Figure
|
## Figure
|
||||||
|
|
||||||
Code:
|
Code:
|
||||||
|
@@ -1,9 +1,14 @@
|
|||||||
{{ $content := .InnerDeindent | strings.TrimLeft "\f\n\r\v" | strings.TrimRight "\f\n\r\t\v " }}
|
{{ $content := .InnerDeindent | strings.TrimLeft "\f\n\r\v" | strings.TrimRight "\f\n\r\t\v " }}
|
||||||
{{ $lang := .Get 0 | default (.Get "lang") | default "plaintext" }}
|
{{ $lang := .Get 0 | default (.Get "lang") | default "plaintext" }}
|
||||||
{{ $options := .Get "options" }}
|
{{ $options := .Get "options" }}
|
||||||
|
{{ $unescape := .Get "unescape" }}
|
||||||
|
|
||||||
{{ if not $content }}
|
{{ if not $content }}
|
||||||
{{ errorf "layouts/shortcodes/paige/code.html: no content" }}
|
{{ errorf "layouts/shortcodes/paige/code.html: no content" }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if $unescape }}
|
||||||
|
{{ $content = htmlUnescape $content }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
<div class="paige-code">{{ highlight $content $lang $options }}</div>
|
<div class="paige-code">{{ highlight $content $lang $options }}</div>
|
||||||
|
Reference in New Issue
Block a user