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 c955433 commit a0f3ac8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 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.
(`hstring.RenderedHTML`) 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.
(`hstring.RenderedHTML`) 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,11 +73,11 @@ block = true

###### Text

(`string`) The image description.
(`hstring.RenderedHTML`) The image description.

###### Title

(`string`) The image title.
(`string`) The image titsle.

Check warning on line 80 in content/en/render-hooks/images.md

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (titsle)

## Examples

Expand Down
6 changes: 3 additions & 3 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.
(`hstring.RenderedHTML`) 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 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.
(`hstring.RenderedHTML`) 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 a0f3ac8

Please sign in to comment.