diff --git a/README.md b/README.md index 18c38aae..f3c1ab6c 100644 --- a/README.md +++ b/README.md @@ -408,11 +408,7 @@ Parameters: None. The `paige/code` shortcode provides a figure with code. ``` -{{< paige/code - caption="My caption" - lang="html" - options="linenos=true" ->}} +{{< paige/code lang="html" options="linenos=true" >}} @@ -427,16 +423,12 @@ Inner content: Required. String. The code. Parameters:
-
caption
-
Optional. String. Markdown. Descriptive text below the code.
lang
Optional. Position 0. String. Chroma language code. Defaults to plaintext. See the codes.
options
Optional. String. Hugo highlight options. See the options.
-It has the other parameters of the `paige/figure` shortcode. - ### Image The `paige/image` shortcode provides a figure with an image. diff --git a/exampleSite/content/shortcodes/code.md b/exampleSite/content/shortcodes/code.md index edf7537f..ea51a224 100644 --- a/exampleSite/content/shortcodes/code.md +++ b/exampleSite/content/shortcodes/code.md @@ -11,6 +11,8 @@ Paige provides a `paige/code` shortcode for displaying code. +## Basic + Code: ```go-text-template @@ -77,12 +79,12 @@ Result: --XXXXXXXXXXXXXXXXXX- {{< /paige/code >}} ---- +## Lang parameter Code: ```go-text-template -{{}} +{{}} float Q_rsqrt( float number ) { long i; @@ -103,7 +105,7 @@ float Q_rsqrt( float number ) Result: -{{< paige/code lang="c" options="linenos=true,hl_lines=10" >}} +{{< paige/code lang="c" >}} float Q_rsqrt( float number ) { long i; @@ -120,3 +122,68 @@ float Q_rsqrt( float number ) return y; } {{< /paige/code >}} + + +## Options parameter + +Code: + +```go-text-template +{{}} +float Q_rsqrt( float number ) +{ + long i; + float x2, y; + const float threehalfs = 1.5F; + + x2 = number * 0.5F; + y = number; + i = * ( long * ) &y; + i = 0x5f3759df - ( i >> 1 ); + y = * ( float * ) &i; + y = y * ( threehalfs - ( x2 * y * y ) ); + + return y; +} +{{}} +``` + +Result: + +{{< paige/code options="linenos=true,hl_lines=10" >}} +float Q_rsqrt( float number ) +{ + long i; + float x2, y; + const float threehalfs = 1.5F; + + x2 = number * 0.5F; + y = number; + i = * ( long * ) &y; + i = 0x5f3759df - ( i >> 1 ); + y = * ( float * ) &i; + y = y * ( threehalfs - ( x2 * y * y ) ); + + return y; +} +{{< /paige/code >}} + +## Figure + +Code: + +```go-text-template +{{}} +{{}} +q = 'q = %r; print(q %% q)'; print(q % q) +{{}} +{{}} +``` + +Result: + +{{< paige/figure caption="Quine" >}} +{{< paige/code lang="python" >}} +q = 'q = %r; print(q %% q)'; print(q % q) +{{< /paige/code >}} +{{< /paige/figure >}} diff --git a/layouts/shortcodes/paige/code.html b/layouts/shortcodes/paige/code.html index fd8ac9c1..4a405a9e 100644 --- a/layouts/shortcodes/paige/code.html +++ b/layouts/shortcodes/paige/code.html @@ -1,27 +1,4 @@ -{{ $caption := .Get "caption" }} -{{ $float := .Get "float" }} -{{ $height := .Get "height" }} -{{ $horizontal := .Get "horizontal" }} {{ $lang := .Get 0 | default (.Get "lang") | default "plaintext" }} -{{ $maxwidth := .Get "maxwidth" }} -{{ $number := .Get "number" }} -{{ $numbered := .Get "numbered" }} {{ $options := .Get "options" }} -{{ $vertical := .Get "vertical" }} -{{ $width := .Get "width" }} -{{ $content := highlight (.Inner | replaceRE "^\n" "") $lang $options }} - -{{ partial "paige/figure.html" (dict - "caption" $caption - "content" $content - "float" $float - "gap" 2 - "height" $height - "horizontal" $horizontal - "maxwidth" $maxwidth - "number" $number - "numbered" $numbered - "vertical" $vertical - "width" $width -) }} +
{{ highlight (.Inner | replaceRE "^\n" "") $lang $options }}