diff --git a/README.md b/README.md index 766ac21b..2408ae48 100644 --- a/README.md +++ b/README.md @@ -511,7 +511,7 @@ title: Search 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 {{< /paige/figure >}} ``` @@ -521,6 +521,8 @@ Parameters:
.Inner
Required. String. Markdown. The inner content.
+
align
+
Optional. String. Horizontal alignment of figure and caption. Must be start, center, or end. Default is center.
caption
Optional. Position 0. String. Markdown. Descriptive text that appears centered below the content.
float
@@ -543,7 +545,7 @@ Parameters:
.Inner
Required. String. Markdown. The inner content.
align
-
Optional. String. Aligns text horizontally. Must be start, center, or end.
+
Optional. String. Horizontal alignment of figure and caption. Must be start, center, or end. Default is center.
caption
Optional. String. Markdown. Descriptive text that appears centered below the quotation. Must not be used with cite.
cite
@@ -557,7 +559,7 @@ Parameters: 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" >}} @@ -572,6 +574,8 @@ Parameters:
.Inner
Required. String. Markdown. The inner content.
+
align
+
Optional. String. Horizontal alignment of figure and caption. Must be start, center, or end. Default is center.
caption
Optional. String. Markdown. Descriptive text that appears centered below the code.
float
@@ -588,6 +592,7 @@ The `paige/image` shortcode provides a figure with a centered image. ``` {{< paige/image + align="center" alt="My alt" >}} caption="My caption" float="left" @@ -605,6 +610,8 @@ The `paige/image` shortcode provides a figure with a centered image. Parameters:
+
align
+
Optional. String. Horizontal alignment of figure and caption. Must be start, center, or end. Default is center.
alt
Optional. String. Plain text. Image alt.
caption
diff --git a/exampleSite/content/blog/quote-shortcode.md b/exampleSite/content/blog/quote-shortcode.md index 0ed8cae6..2ea85c20 100644 --- a/exampleSite/content/blog/quote-shortcode.md +++ b/exampleSite/content/blog/quote-shortcode.md @@ -40,22 +40,6 @@ Don't believe everything you read on the Internet. Code: -```go-text-template -{{}} -Don't believe everything you read on the Internet. -{{}} -``` - -Result: - -{{< paige/quote cite="Abraham Lincoln" >}} -Don't believe everything you read on the Internet. -{{< /paige/quote >}} - ---- - -Code: - ```go-text-template {{}} Don't believe everything you read on the Internet. @@ -81,31 +65,7 @@ Use the Force, Harry. Code: ```go-text-template -{{}} -Don't believe everything you read on the Internet. -{{}} - -{{}} -Use the Force, Harry. -{{}} -``` - -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 -{{}} +{{}} Don't believe everything you read on the Internet. {{}} @@ -114,7 +74,7 @@ Michael was having brunch with Sally Sitwell at a restaurant called Skip Church' Result: -{{< paige/quote cite="Abraham Lincoln" float="end" >}} +{{< paige/quote caption="Abraham Lincoln" float="end" >}} Don't believe everything you read on the Internet. {{< /paige/quote >}} @@ -133,7 +93,15 @@ The mouse ran down, Hickory dickory dock. {{}} -{{}} +{{}} +
Hickory dickory dock. +The mouse ran up the clock. +The clock struck one, +The mouse ran down, +Hickory dickory dock.
+{{}} + +{{}}
Hickory dickory dock. The mouse ran up the clock. The clock struck one, @@ -152,7 +120,15 @@ The mouse ran down, Hickory dickory dock.
{{< /paige/quote >}} -{{< paige/quote cite="Hickory Dickory Dock" align="end" >}} +{{< paige/quote caption="Hickory Dickory Dock" align="center" >}} +
Hickory dickory dock. +The mouse ran up the clock. +The clock struck one, +The mouse ran down, +Hickory dickory dock.
+{{< /paige/quote >}} + +{{< paige/quote caption="Hickory Dickory Dock" align="end" >}}
Humpty Dumpty sat on a wall, Humpty Dumpty had a great fall. All the king's horses and all the king's men diff --git a/layouts/partials/paige/figure.html b/layouts/partials/paige/figure.html index b632192a..b9896c52 100644 --- a/layouts/partials/paige/figure.html +++ b/layouts/partials/paige/figure.html @@ -1,11 +1,26 @@ +{{ $align := .align | default "center" }} {{ $caption := .caption | markdownify }} +{{ $compact := .compact }} {{ $content := .content | markdownify }} {{ $float := .float }} +{{ $gap := .gap | default "2" }} {{ $height := .height }} {{ $maxheight := .maxheight }} {{ $maxwidth := .maxwidth }} {{ $width := .width }} +{{ $bottommargin := true }} + +{{ if $compact }} + {{ $bottommargin = false }} +{{ end }} + +{{ $table := false }} + +{{ if or $compact $float }} + {{ $table = true }} +{{ end }} + {{ $style := "" }} {{ if $height }} @@ -48,27 +63,28 @@ {{ end }} {{ end }} -{{ $margin := "" }} +{{ $sidemargin := "" }} + {{ if $float }} {{ if eq $float "start" }} - {{ $margin = "me-4" }} + {{ $sidemargin = "me-4" }} {{ else if eq $float "end" }} - {{ $margin = "ms-4" }} + {{ $sidemargin = "ms-4" }} {{ else }} {{ errorf "invalid float: %q" $float }} {{ end }} {{ end }} -
-
- {{ if $float }} +
+
+ {{ if $table }}
{{ end }} -
{{ $content }}
+
{{ $content }}
{{ with $caption }} -
{{ . }}
+
{{ . }}
{{ end }} - {{ if $float }} + {{ if $table }}
{{ end }}
diff --git a/layouts/partials/paige/image-figure.html b/layouts/partials/paige/image-figure.html index 138dc5f1..1c95bbde 100644 --- a/layouts/partials/paige/image-figure.html +++ b/layouts/partials/paige/image-figure.html @@ -1,5 +1,6 @@ {{ $alt := .alt }} {{ $caption := .caption }} +{{ $compact := .compact }} {{ $float := .float }} {{ $height := .height }} {{ $link := .link }} @@ -7,7 +8,6 @@ {{ $maxwidth := .maxwidth }} {{ $method := .method }} {{ $options := .options }} -{{ $packed := .packed }} {{ $page := .page }} {{ $resource := .resource }} {{ $src := .src }} @@ -33,70 +33,13 @@ ) }} {{ end }} -{{ $style := "" }} - -{{ if $height }} - {{ with printf "height: %v" $height }} - {{ if $style }} - {{ $style = printf "%v; %v" $style . }} - {{ else }} - {{ $style = . }} - {{ end }} - {{ 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 }} - -
-
- {{ if or $float $table }} -
- {{ end }} -
{{ $content }}
- {{ with $caption }} -
{{ . }}
- {{ end }} - {{ if or $float $table }} -
- {{ end }} -
-
+{{ partial "paige/figure.html" (dict + "caption" $caption + "compact" $compact + "content" $content + "float" $float + "height" $height + "maxheight" $maxheight + "maxwidth" $maxwidth + "width" $width +) }} diff --git a/layouts/shortcodes/paige/code.html b/layouts/shortcodes/paige/code.html index 2673399c..08f6d546 100644 --- a/layouts/shortcodes/paige/code.html +++ b/layouts/shortcodes/paige/code.html @@ -1,3 +1,4 @@ +{{ $align := .Get "align" }} {{ $caption := .Get "caption" }} {{ $float := .Get "float" }} {{ $lang := .Get 0 | default (.Get "lang") | default "plaintext" }} @@ -6,6 +7,7 @@ {{ $content := highlight (.Inner | replaceRE "^\n" "") $lang $options }} {{ partial "paige/figure.html" (dict + "align" $align "caption" $caption "content" $content "float" $float diff --git a/layouts/shortcodes/paige/figure.html b/layouts/shortcodes/paige/figure.html index 4d36d129..170a3037 100644 --- a/layouts/shortcodes/paige/figure.html +++ b/layouts/shortcodes/paige/figure.html @@ -1,3 +1,4 @@ +{{ $align := .Get "align" }} {{ $caption := .Get 0 | default (.Get "caption") }} {{ $float := .Get "float" }} {{ $height := .Get "height" }} @@ -8,6 +9,7 @@ {{ $content := .Inner }} {{ partial "paige/figure.html" (dict + "align" $align "caption" $caption "content" $content "float" $float diff --git a/layouts/shortcodes/paige/gallery.html b/layouts/shortcodes/paige/gallery.html index 060fe638..80d55360 100644 --- a/layouts/shortcodes/paige/gallery.html +++ b/layouts/shortcodes/paige/gallery.html @@ -19,13 +19,13 @@ {{ partial "paige/image-figure.html" (dict "caption" $caption + "compact" true "height" $height "link" $resource.RelPermalink "maxheight" $maxheight "maxwidth" $maxwidth "method" $method "options" $options - "packed" true "page" .Page "resource" $resource "src" $image diff --git a/layouts/shortcodes/paige/image.html b/layouts/shortcodes/paige/image.html index 5b8c5748..a1722a3d 100644 --- a/layouts/shortcodes/paige/image.html +++ b/layouts/shortcodes/paige/image.html @@ -1,3 +1,4 @@ +{{ $align := .Get "align" }} {{ $alt := .Get "alt" }} {{ $caption := .Get "caption" }} {{ $float := .Get "float" }} @@ -12,6 +13,7 @@ {{ $width := .Get "width" }} {{ partial "paige/image-figure.html" (dict + "align" $align "alt" $alt "caption" $caption "float" $float diff --git a/layouts/shortcodes/paige/quote.html b/layouts/shortcodes/paige/quote.html index 4756d877..1e0c6d24 100644 --- a/layouts/shortcodes/paige/quote.html +++ b/layouts/shortcodes/paige/quote.html @@ -1,87 +1,22 @@ -{{ $align := .Get "align" | default "center" }} +{{ $align := .Get "align" }} {{ $caption := .Get "caption" | markdownify }} -{{ $cite := (.Get 0 | default (.Get "cite")) | markdownify }} +{{ $content := .Inner | markdownify }} {{ $float := .Get "float" }} {{ $height := .Get "height" }} {{ $maxheight := .Get "maxheight" }} {{ $maxwidth := .Get "maxwidth" }} {{ $width := .Get "width" }} -{{ $content := .Inner | markdownify }} - -{{ $style := "" }} - -{{ if $height }} - {{ with printf "height: %v" $height }} - {{ if $style }} - {{ $style = printf "%v; %v" $style . }} - {{ else }} - {{ $style = . }} - {{ end }} - {{ 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 }} - -
-
- {{ if $float }} -
- {{ end }} - {{ if $caption }} -
- {{ end }} -
{{ $content }}
- {{ if $caption }} -
- {{ end }} - {{ with $caption }} -
{{ . }}
- {{ end }} - {{ with $cite }} - - {{ end }} - {{ if $float }} -
- {{ end }} -
-
+{{ $content = printf `
%v
` $align $content | safeHTML }} + +{{ partial "paige/figure.html" (dict + "align" $align + "caption" $caption + "content" $content + "float" $float + "gap" "0" + "height" $height + "maxheight" $maxheight + "maxwidth" $maxwidth + "width" $width +) }}