Skip to content

Commit

Permalink
Document change to data type returned by render hook Text methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jmooring committed Aug 31, 2024
1 parent 4e321df commit 4a7638b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
12 changes: 5 additions & 7 deletions content/en/render-hooks/blockquotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ block = true
(`string`) The position of the blockquote within the page content.

###### Text
(`string`) The blockquote text, excluding the alert designator if present. See the [alerts](#alerts) section below.
(`template.HTML`) The blockquote text, excluding the alert designator if present. See the [alerts](#alerts) section below.

###### Type

Expand All @@ -68,7 +68,7 @@ In its default configuration, Hugo renders Markdown blockquotes according to the

{{< code file=layouts/_default/_markup/render-blockquote.html copy=true >}}
<blockquote>
{{ .Text | safeHTML }}
{{ .Text }}
</blockquote>
{{< /code >}}

Expand All @@ -77,7 +77,7 @@ To render a blockquote as an HTML `figure` element with an optional citation and
{{< code file=layouts/_default/_markup/render-blockquote.html copy=true >}}
<figure>
<blockquote {{ with .Attributes.cite }}cite="{{ . }}"{{ end }}>
{{ .Text | safeHTML }}
{{ .Text }}
</blockquote>
{{ with .Attributes.caption }}
<figcaption class="blockquote-caption">
Expand Down Expand Up @@ -115,12 +115,10 @@ Also known as _callouts_ or _admonitions_, alerts are blockquotes used to emphas
> Advises about risks or negative outcomes of certain actions.
{{< /code >}}

{{% note %}}
This syntax is compatible with the GitHub Alert Markdown extension.
{{% /note %}}


The first line of each alert is an alert designator consisting of an exclamation point followed by the alert type, wrapped within brackets.

The blockquote render hook below renders a multilingual alert if an alert desginator is present, otherwise it renders a blockquote according to the CommonMark specification.
Expand All @@ -140,11 +138,11 @@ The blockquote render hook below renders a multilingual alert if an alert desgin
{{ transform.Emojify (index $emojis .AlertType) }}
{{ or (i18n .AlertType) (title .AlertType) }}
</p>
{{ .Text | safeHTML }}
{{ .Text }}
</blockquote>
{{ else }}
<blockquote>
{{ .Text | safeHTML }}
{{ .Text }}
</blockquote>
{{ end }}
{{< /code >}}
Expand Down
6 changes: 3 additions & 3 deletions content/en/render-hooks/headings.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ title = true

###### Text

(`string`) The heading text.
(`template.HTML`) The heading text.

## Examples

Expand All @@ -65,15 +65,15 @@ In its default configuration, Hugo renders Markdown headings according to the [C

{{< code file=layouts/_default/_markup/render-heading.html copy=true >}}
<h{{ .Level }} id="{{ .Anchor }}">
{{- .Text | safeHTML -}}
{{- .Text -}}
</h{{ .Level }}>
{{< /code >}}

To add an anchor link to the right of each heading:

{{< code file=layouts/_default/_markup/render-heading.html copy=true >}}
<h{{ .Level }} id="{{ .Anchor }}">
{{ .Text | safeHTML }}
{{ .Text }}
<a href="#{{ .Anchor }}">#</a>
</h{{ .Level }}>
{{< /code >}}
Expand Down
4 changes: 2 additions & 2 deletions content/en/render-hooks/images.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ block = true

###### Text

(`string`) The image description.
(`template.HTML`) The image description.

###### Title

Expand Down Expand Up @@ -143,7 +143,7 @@ The embedded image render hook is automatically enabled for multilingual single-
[duplication of shared page resources]: /getting-started/configuration-markup/#duplicateresourcefiles
{{% /note %}}

The embedded image render hook resolves internal Markdown destinations by looking for a matching [page resource], falling back to a matching [global resource]. Remote destinations are passed through, and the render hook will not throw an error or warning if it is unable to resolve a destination.
The embedded image render hook resolves internal Markdown destinations by looking for a matching [page resource], falling back to a matching [global resource]. Remote destinations are passed through, and the render hook will not throw an error or warning if unable to resolve a destination.

[page resource]: /getting-started/glossary/#page-resource
[global resource]: /getting-started/glossary/#global-resource
Expand Down
8 changes: 4 additions & 4 deletions content/en/render-hooks/links.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Link render hook templates receive the following context:

###### Text

(`string`) The link description.
(`template.HTML`) The link description.

###### Title

Expand All @@ -74,7 +74,7 @@ In its default configuration, Hugo renders Markdown links according to the [Comm
<a href="{{ .Destination | safeURL }}"
{{- with .Title }} title="{{ . }}"{{ end -}}
>
{{- with .Text | safeHTML }}{{ . }}{{ end -}}
{{- with .Text }}{{ . }}{{ end -}}
</a>
{{- /* chomp trailing newline */ -}}
{{< /code >}}
Expand All @@ -87,7 +87,7 @@ To include a `rel` attribute set to `external` for external links:
{{- with .Title }} title="{{ . }}"{{ end -}}
{{- if $u.IsAbs }} rel="external"{{ end -}}
>
{{- with .Text | safeHTML }}{{ . }}{{ end -}}
{{- with .Text }}{{ . }}{{ end -}}
</a>
{{- /* chomp trailing newline */ -}}
{{< /code >}}
Expand All @@ -113,7 +113,7 @@ The embedded link render hook is automatically enabled for multilingual single-h
[duplication of shared page resources]: /getting-started/configuration-markup/#duplicateresourcefiles
{{% /note %}}

The embedded link render hook resolves internal Markdown destinations by looking for a matching page, falling back to a matching [page resource], then falling back to a matching [global resource]. Remote destinations are passed through, and the render hook will not throw an error or warning if it is unable to resolve a destination.
The embedded link render hook resolves internal Markdown destinations by looking for a matching page, falling back to a matching [page resource], then falling back to a matching [global resource]. Remote destinations are passed through, and the render hook will not throw an error or warning if unable to resolve a destination.

[page resource]: /getting-started/glossary/#page-resource
[global resource]: /getting-started/glossary/#global-resource
Expand Down
6 changes: 3 additions & 3 deletions content/en/render-hooks/tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Each table cell within the slice of slices returned by the `THead` and `TBody` m
(`string`) The alignment of the text within the table cell, one of `left`, `center`, or `right`.

###### Text
(`string`) The text within the table cell.
(`template.HTML`) The text within the table cell.

## Example

Expand All @@ -83,7 +83,7 @@ In its default configuration, Hugo renders Markdown tables according to the [Git
<tr>
{{- range . }}
<th {{ printf "style=%q" (printf "text-align: %s" .Alignment) | safeHTMLAttr }}>
{{- .Text | safeHTML -}}
{{- .Text -}}
</th>
{{- end }}
</tr>
Expand All @@ -94,7 +94,7 @@ In its default configuration, Hugo renders Markdown tables according to the [Git
<tr>
{{- range . }}
<td {{ printf "style=%q" (printf "text-align: %s" .Alignment) | safeHTMLAttr }}>
{{- .Text | safeHTML -}}
{{- .Text -}}
</td>
{{- end }}
</tr>
Expand Down

0 comments on commit 4a7638b

Please sign in to comment.