Add align param

master
Will Faught 3 years ago
parent c578d235d2
commit ec03a86297

@ -511,7 +511,7 @@ title: Search
The `paige/figure` shortcode provides a figure with centered content. The `paige/figure` shortcode provides a figure with centered content.
``` ```
{{< paige/figure caption="My caption" float="left" >}} {{< paige/figure align="center" caption="My caption" float="left" >}}
My content My content
{{< /paige/figure >}} {{< /paige/figure >}}
``` ```
@ -521,6 +521,8 @@ Parameters:
<dl> <dl>
<dt><code>.Inner</code></dt> <dt><code>.Inner</code></dt>
<dd>Required. String. Markdown. The inner content.</dd> <dd>Required. String. Markdown. The inner content.</dd>
<dt><code>align</code></dt>
<dd>Optional. String. Horizontal alignment of figure and caption. Must be <code>start</code>, <code>center</code>, or <code>end</code>. Default is <code>center</code>.</dd>
<dt><code>caption</code></dt> <dt><code>caption</code></dt>
<dd>Optional. Position 0. String. Markdown. Descriptive text that appears centered below the content.</dd> <dd>Optional. Position 0. String. Markdown. Descriptive text that appears centered below the content.</dd>
<dt><code>float</code></dt> <dt><code>float</code></dt>
@ -543,7 +545,7 @@ Parameters:
<dt><code>.Inner</code></dt> <dt><code>.Inner</code></dt>
<dd>Required. String. Markdown. The inner content.</dd> <dd>Required. String. Markdown. The inner content.</dd>
<dt><code>align</code></dt> <dt><code>align</code></dt>
<dd>Optional. String. Aligns text horizontally. Must be <code>start</code>, <code>center</code>, or <code>end</code>.</dd> <dd>Optional. String. Horizontal alignment of figure and caption. Must be <code>start</code>, <code>center</code>, or <code>end</code>. Default is <code>center</code>.</dd>
<dt><code>caption</code></dt> <dt><code>caption</code></dt>
<dd>Optional. String. Markdown. Descriptive text that appears centered below the quotation. Must not be used with <code>cite</code>.</dd> <dd>Optional. String. Markdown. Descriptive text that appears centered below the quotation. Must not be used with <code>cite</code>.</dd>
<dt><code>cite</code></dt> <dt><code>cite</code></dt>
@ -557,7 +559,7 @@ Parameters:
The `paige/code` shortcode provides a figure with centered code. The `paige/code` shortcode provides a figure with centered code.
``` ```
{{< paige/code caption="My caption" float="left" lang="html" options="linenos=true" >}} {{< paige/code align="center" caption="My caption" float="left" lang="html" options="linenos=true" >}}
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<body> <body>
@ -572,6 +574,8 @@ Parameters:
<dl> <dl>
<dt><code>.Inner</code></dt> <dt><code>.Inner</code></dt>
<dd>Required. String. Markdown. The inner content.</dd> <dd>Required. String. Markdown. The inner content.</dd>
<dt><code>align</code></dt>
<dd>Optional. String. Horizontal alignment of figure and caption. Must be <code>start</code>, <code>center</code>, or <code>end</code>. Default is <code>center</code>.</dd>
<dt><code>caption</code></dt> <dt><code>caption</code></dt>
<dd>Optional. String. Markdown. Descriptive text that appears centered below the code.</dd> <dd>Optional. String. Markdown. Descriptive text that appears centered below the code.</dd>
<dt><code>float</code></dt> <dt><code>float</code></dt>
@ -588,6 +592,7 @@ The `paige/image` shortcode provides a figure with a centered image.
``` ```
{{< paige/image {{< paige/image
align="center"
alt="My alt" >}} alt="My alt" >}}
caption="My caption" caption="My caption"
float="left" float="left"
@ -605,6 +610,8 @@ The `paige/image` shortcode provides a figure with a centered image.
Parameters: Parameters:
<dl> <dl>
<dt><code>align</code></dt>
<dd>Optional. String. Horizontal alignment of figure and caption. Must be <code>start</code>, <code>center</code>, or <code>end</code>. Default is <code>center</code>.</dd>
<dt><code>alt</code></dt> <dt><code>alt</code></dt>
<dd>Optional. String. Plain text. Image alt.</dd> <dd>Optional. String. Plain text. Image alt.</dd>
<dt><code>caption</code></dt> <dt><code>caption</code></dt>

@ -40,22 +40,6 @@ Don't believe everything you read on the Internet.
Code: Code:
```go-text-template
{{</* paige/quote cite="Abraham Lincoln" */>}}
Don't believe everything you read on the Internet.
{{</* /paige/quote */>}}
```
Result:
{{< paige/quote cite="Abraham Lincoln" >}}
Don't believe everything you read on the Internet.
{{< /paige/quote >}}
---
Code:
```go-text-template ```go-text-template
{{</* paige/quote */>}} {{</* paige/quote */>}}
Don't believe everything you read on the Internet. Don't believe everything you read on the Internet.
@ -81,31 +65,7 @@ Use the Force, Harry.
Code: Code:
```go-text-template ```go-text-template
{{</* paige/quote cite="Abraham Lincoln" */>}} {{</* paige/quote caption="Abraham Lincoln" float="end" */>}}
Don't believe everything you read on the Internet.
{{</* /paige/quote */>}}
{{</* paige/quote cite="Gandalf" */>}}
Use the Force, Harry.
{{</* /paige/quote */>}}
```
Result:
{{< paige/quote cite="Abraham Lincoln" >}}
Don't believe everything you read on the Internet.
{{< /paige/quote >}}
{{< paige/quote cite="Gandalf" >}}
Use the Force, Harry.
{{< /paige/quote >}}
---
Code:
```go-text-template
{{</* paige/quote cite="Abraham Lincoln" float="end" */>}}
Don't believe everything you read on the Internet. Don't believe everything you read on the Internet.
{{</* /paige/quote */>}} {{</* /paige/quote */>}}
@ -114,7 +74,7 @@ Michael was having brunch with Sally Sitwell at a restaurant called Skip Church'
Result: Result:
{{< paige/quote cite="Abraham Lincoln" float="end" >}} {{< paige/quote caption="Abraham Lincoln" float="end" >}}
Don't believe everything you read on the Internet. Don't believe everything you read on the Internet.
{{< /paige/quote >}} {{< /paige/quote >}}
@ -133,7 +93,15 @@ The mouse ran down,
Hickory dickory dock.</div> Hickory dickory dock.</div>
{{</* /paige/quote */>}} {{</* /paige/quote */>}}
{{</* paige/quote cite="Hickory Dickory Dock" align="end" */>}} {{</* paige/quote caption="Hickory Dickory Dock" align="center" */>}}
<div style="white-space: pre">Hickory dickory dock.
The mouse ran up the clock.
The clock struck one,
The mouse ran down,
Hickory dickory dock.</div>
{{</* /paige/quote */>}}
{{</* paige/quote caption="Hickory Dickory Dock" align="end" */>}}
<div style="white-space: pre">Hickory dickory dock. <div style="white-space: pre">Hickory dickory dock.
The mouse ran up the clock. The mouse ran up the clock.
The clock struck one, The clock struck one,
@ -152,7 +120,15 @@ The mouse ran down,
Hickory dickory dock.</div> Hickory dickory dock.</div>
{{< /paige/quote >}} {{< /paige/quote >}}
{{< paige/quote cite="Hickory Dickory Dock" align="end" >}} {{< paige/quote caption="Hickory Dickory Dock" align="center" >}}
<div style="white-space: pre">Hickory dickory dock.
The mouse ran up the clock.
The clock struck one,
The mouse ran down,
Hickory dickory dock.</div>
{{< /paige/quote >}}
{{< paige/quote caption="Hickory Dickory Dock" align="end" >}}
<div style="white-space: pre">Humpty Dumpty sat on a wall, <div style="white-space: pre">Humpty Dumpty sat on a wall,
Humpty Dumpty had a great fall. Humpty Dumpty had a great fall.
All the king's horses and all the king's men All the king's horses and all the king's men

@ -1,11 +1,26 @@
{{ $align := .align | default "center" }}
{{ $caption := .caption | markdownify }} {{ $caption := .caption | markdownify }}
{{ $compact := .compact }}
{{ $content := .content | markdownify }} {{ $content := .content | markdownify }}
{{ $float := .float }} {{ $float := .float }}
{{ $gap := .gap | default "2" }}
{{ $height := .height }} {{ $height := .height }}
{{ $maxheight := .maxheight }} {{ $maxheight := .maxheight }}
{{ $maxwidth := .maxwidth }} {{ $maxwidth := .maxwidth }}
{{ $width := .width }} {{ $width := .width }}
{{ $bottommargin := true }}
{{ if $compact }}
{{ $bottommargin = false }}
{{ end }}
{{ $table := false }}
{{ if or $compact $float }}
{{ $table = true }}
{{ end }}
{{ $style := "" }} {{ $style := "" }}
{{ if $height }} {{ if $height }}
@ -48,27 +63,28 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ $margin := "" }} {{ $sidemargin := "" }}
{{ if $float }} {{ if $float }}
{{ if eq $float "start" }} {{ if eq $float "start" }}
{{ $margin = "me-4" }} {{ $sidemargin = "me-4" }}
{{ else if eq $float "end" }} {{ else if eq $float "end" }}
{{ $margin = "ms-4" }} {{ $sidemargin = "ms-4" }}
{{ else }} {{ else }}
{{ errorf "invalid float: %q" $float }} {{ errorf "invalid float: %q" $float }}
{{ end }} {{ end }}
{{ end }} {{ end }}
<figure class="{{ with $float }} float-{{ . }} {{ $margin }} {{ end }} align-items-center d-flex flex-column justify-content-center paige-figure" {{ if $float }} {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ end }}> <figure class="{{ with $float }} float-{{ . }} {{ $sidemargin }} {{ end }} {{ if not $bottommargin }} mb-0 {{ end }} align-items-{{ $align }} d-flex flex-column justify-content-center paige-figure" {{ if $float }} {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ end }}>
<div class="align-items-center d-flex flex-column justify-content-center {{ if and $float $height }} h-100 {{ end }}" {{ if not $float }} {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ end }}> <div class="align-items-{{ $align }} d-flex flex-column justify-content-center {{ if and $float $height }} h-100 {{ end }}" {{ if not $float }} {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ end }}>
{{ if $float }} {{ if $table }}
<div class="d-table"> <div class="d-table">
{{ end }} {{ end }}
<div {{ if $caption }} class="mb-2" {{ end }}>{{ $content }}</div> <div>{{ $content }}</div>
{{ with $caption }} {{ with $caption }}
<figcaption class="figure-caption text-center" {{ if $float }} style="caption-side: bottom; display: table-caption" {{ end }}>{{ . }}</figcaption> <figcaption class="figure-caption mt-{{ $gap }} text-{{ $align }}" {{ if $table }} style="caption-side: bottom; display: table-caption" {{ end }}>{{ . }}</figcaption>
{{ end }} {{ end }}
{{ if $float }} {{ if $table }}
</div> </div>
{{ end }} {{ end }}
</div> </div>

@ -1,5 +1,6 @@
{{ $alt := .alt }} {{ $alt := .alt }}
{{ $caption := .caption }} {{ $caption := .caption }}
{{ $compact := .compact }}
{{ $float := .float }} {{ $float := .float }}
{{ $height := .height }} {{ $height := .height }}
{{ $link := .link }} {{ $link := .link }}
@ -7,7 +8,6 @@
{{ $maxwidth := .maxwidth }} {{ $maxwidth := .maxwidth }}
{{ $method := .method }} {{ $method := .method }}
{{ $options := .options }} {{ $options := .options }}
{{ $packed := .packed }}
{{ $page := .page }} {{ $page := .page }}
{{ $resource := .resource }} {{ $resource := .resource }}
{{ $src := .src }} {{ $src := .src }}
@ -33,70 +33,13 @@
) }} ) }}
{{ end }} {{ end }}
{{ $style := "" }} {{ partial "paige/figure.html" (dict
"caption" $caption
{{ if $height }} "compact" $compact
{{ with printf "height: %v" $height }} "content" $content
{{ if $style }} "float" $float
{{ $style = printf "%v; %v" $style . }} "height" $height
{{ else }} "maxheight" $maxheight
{{ $style = . }} "maxwidth" $maxwidth
{{ end }} "width" $width
{{ end }} ) }}
{{ end }}
{{ if $maxheight }}
{{ with printf "max-height: %v" $maxheight }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ if $maxwidth }}
{{ with printf "max-width: %v" $maxwidth }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ if $width }}
{{ with printf "width: %v" $width }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ $margin := "" }}
{{ if $float }}
{{ if eq $float "start" }}
{{ $margin = "me-4" }}
{{ else if eq $float "end" }}
{{ $margin = "ms-4" }}
{{ else }}
{{ errorf "invalid float: %q" $float }}
{{ end }}
{{ end }}
<figure class="{{ if $float }} float-{{ $float }} {{ $margin }} {{ else if $packed }} mb-0 {{ end }} align-items-center d-flex flex-column justify-content-center paige-figure" {{ if $float }} {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ end }}>
<div class="align-items-center d-flex flex-column justify-content-center {{ if and $float $height }} h-100 {{ end }}" {{ if not $float }} {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ end }}>
{{ if or $float $table }}
<div class="d-table">
{{ end }}
<div {{ if $caption }} class="mb-2" {{ end }}>{{ $content }}</div>
{{ with $caption }}
<figcaption class="figure-caption text-center" {{ if or $float $table }} style="caption-side: bottom; display: table-caption" {{ end }}>{{ . }}</figcaption>
{{ end }}
{{ if or $float $table }}
</div>
{{ end }}
</div>
</figure>

@ -1,3 +1,4 @@
{{ $align := .Get "align" }}
{{ $caption := .Get "caption" }} {{ $caption := .Get "caption" }}
{{ $float := .Get "float" }} {{ $float := .Get "float" }}
{{ $lang := .Get 0 | default (.Get "lang") | default "plaintext" }} {{ $lang := .Get 0 | default (.Get "lang") | default "plaintext" }}
@ -6,6 +7,7 @@
{{ $content := highlight (.Inner | replaceRE "^\n" "") $lang $options }} {{ $content := highlight (.Inner | replaceRE "^\n" "") $lang $options }}
{{ partial "paige/figure.html" (dict {{ partial "paige/figure.html" (dict
"align" $align
"caption" $caption "caption" $caption
"content" $content "content" $content
"float" $float "float" $float

@ -1,3 +1,4 @@
{{ $align := .Get "align" }}
{{ $caption := .Get 0 | default (.Get "caption") }} {{ $caption := .Get 0 | default (.Get "caption") }}
{{ $float := .Get "float" }} {{ $float := .Get "float" }}
{{ $height := .Get "height" }} {{ $height := .Get "height" }}
@ -8,6 +9,7 @@
{{ $content := .Inner }} {{ $content := .Inner }}
{{ partial "paige/figure.html" (dict {{ partial "paige/figure.html" (dict
"align" $align
"caption" $caption "caption" $caption
"content" $content "content" $content
"float" $float "float" $float

@ -19,13 +19,13 @@
{{ partial "paige/image-figure.html" (dict {{ partial "paige/image-figure.html" (dict
"caption" $caption "caption" $caption
"compact" true
"height" $height "height" $height
"link" $resource.RelPermalink "link" $resource.RelPermalink
"maxheight" $maxheight "maxheight" $maxheight
"maxwidth" $maxwidth "maxwidth" $maxwidth
"method" $method "method" $method
"options" $options "options" $options
"packed" true
"page" .Page "page" .Page
"resource" $resource "resource" $resource
"src" $image "src" $image

@ -1,3 +1,4 @@
{{ $align := .Get "align" }}
{{ $alt := .Get "alt" }} {{ $alt := .Get "alt" }}
{{ $caption := .Get "caption" }} {{ $caption := .Get "caption" }}
{{ $float := .Get "float" }} {{ $float := .Get "float" }}
@ -12,6 +13,7 @@
{{ $width := .Get "width" }} {{ $width := .Get "width" }}
{{ partial "paige/image-figure.html" (dict {{ partial "paige/image-figure.html" (dict
"align" $align
"alt" $alt "alt" $alt
"caption" $caption "caption" $caption
"float" $float "float" $float

@ -1,87 +1,22 @@
{{ $align := .Get "align" | default "center" }} {{ $align := .Get "align" }}
{{ $caption := .Get "caption" | markdownify }} {{ $caption := .Get "caption" | markdownify }}
{{ $cite := (.Get 0 | default (.Get "cite")) | markdownify }} {{ $content := .Inner | markdownify }}
{{ $float := .Get "float" }} {{ $float := .Get "float" }}
{{ $height := .Get "height" }} {{ $height := .Get "height" }}
{{ $maxheight := .Get "maxheight" }} {{ $maxheight := .Get "maxheight" }}
{{ $maxwidth := .Get "maxwidth" }} {{ $maxwidth := .Get "maxwidth" }}
{{ $width := .Get "width" }} {{ $width := .Get "width" }}
{{ $content := .Inner | markdownify }} {{ $content = printf `<blockquote class="blockquote mb-0 text-%v">%v</blockquote>` $align $content | safeHTML }}
{{ $style := "" }} {{ partial "paige/figure.html" (dict
"align" $align
{{ if $height }} "caption" $caption
{{ with printf "height: %v" $height }} "content" $content
{{ if $style }} "float" $float
{{ $style = printf "%v; %v" $style . }} "gap" "0"
{{ else }} "height" $height
{{ $style = . }} "maxheight" $maxheight
{{ end }} "maxwidth" $maxwidth
{{ end }} "width" $width
{{ end }} ) }}
{{ if $maxheight }}
{{ with printf "max-height: %v" $maxheight }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ if $maxwidth }}
{{ with printf "max-width: %v" $maxwidth }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ if $width }}
{{ with printf "width: %v" $width }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ $margin := "" }}
{{ if $float }}
{{ if eq $float "start" }}
{{ $margin = "me-4" }}
{{ else if eq $float "end" }}
{{ $margin = "ms-4" }}
{{ else }}
{{ errorf "invalid float: %q" $float }}
{{ end }}
{{ end }}
<figure class="{{ with $float }} float-{{ . }} {{ $margin }} {{ end }} align-items-center d-flex flex-column justify-content-center paige-figure" {{ if $float }} {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ end }}>
<div class="align-items-center d-flex flex-column justify-content-center {{ if and $float $height }} h-100 {{ end }}" {{ if not $float }} {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ end }}>
{{ if $float }}
<div class="d-table">
{{ end }}
{{ if $caption }}
<div class="mb-2">
{{ end }}
<blockquote class="blockquote {{ if not $cite }} mb-0 {{ end }} text-{{ $align }}">{{ $content }}</blockquote>
{{ if $caption }}
</div>
{{ end }}
{{ with $caption }}
<figcaption class="figure-caption text-center" {{ if $float }} style="caption-side: bottom; display: table-caption" {{ end }}>{{ . }}</figcaption>
{{ end }}
{{ with $cite }}
<figcaption class="blockquote-footer figure-caption mb-0 text-{{ $align }}">{{ . }}</figcaption>
{{ end }}
{{ if $float }}
</div>
{{ end }}
</div>
</figure>

Loading…
Cancel
Save