mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
Merge commit 'de0df119b504a91c9e1f442b07954f366ffb2932'
This commit is contained in:
@@ -12,26 +12,17 @@ action:
|
||||
aliases: [/functions/cond]
|
||||
---
|
||||
|
||||
The CONTROL argument is a boolean value that indicates whether the function should return ARG1 or ARG2. If CONTROL is `true`, the function returns ARG1. Otherwise, the function returns ARG2.
|
||||
If CONTROL is truthy the function returns ARG1, otherwise it returns ARG2.
|
||||
|
||||
```go-html-template
|
||||
{{ $qty := 42 }}
|
||||
{{ cond (le $qty 3) "few" "many" }} → many
|
||||
```
|
||||
|
||||
The CONTROL argument must be either `true` or `false`. To cast a non-boolean value to boolean, pass it through the `not` operator twice.
|
||||
|
||||
```go-html-template
|
||||
{{ cond (42 | not | not) "truthy" "falsy" }} → truthy
|
||||
{{ cond ("" | not | not) "truthy" "falsy" }} → falsy
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
Unlike [ternary operators] in other languages, the `cond` function does not perform [short-circuit evaluation]. The function evaluates both ARG1 and ARG2, regardless of the CONTROL value.
|
||||
Unlike [ternary operators] in other languages, the `compare.Conditional` function does not perform [short-circuit evaluation]. It evaluates both ARG1 and ARG2 regardless of the CONTROL value.
|
||||
|
||||
[short-circuit evaluation]: https://en.wikipedia.org/wiki/Short-circuit_evaluation
|
||||
[ternary operators]: https://en.wikipedia.org/wiki/Ternary_conditional_operator
|
||||
{{% /note %}}
|
||||
|
||||
Due to the absence of short-circuit evaluation, these examples throw an error:
|
||||
|
||||
|
@@ -32,7 +32,7 @@ toc: true
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
Transpile Sass to CSS using the LibSass transpiler included in Hugo's extended edition, or [install Dart Sass](#dart-sass) to use the latest features of the Sass language.
|
||||
Transpile Sass to CSS using the LibSass transpiler included in Hugo's extended and extended/deploy editions, or [install Dart Sass](#dart-sass) to use the latest features of the Sass language.
|
||||
|
||||
Sass has two forms of syntax: [SCSS] and [indented]. Hugo supports both.
|
||||
|
||||
@@ -42,7 +42,7 @@ Sass has two forms of syntax: [SCSS] and [indented]. Hugo supports both.
|
||||
## Options
|
||||
|
||||
transpiler
|
||||
: (`string`) The transpiler to use, either `libsass` (default) or `dartsass`. Hugo's extended edition includes the LibSass transpiler. To use the Dart Sass transpiler, see the [installation instructions](#dart-sass) below.
|
||||
: (`string`) The transpiler to use, either `libsass` (default) or `dartsass`. Hugo's extended and extended/deploy editions include the LibSass transpiler. To use the Dart Sass transpiler, see the [installation instructions](#dart-sass) below.
|
||||
|
||||
targetPath
|
||||
: (`string`) If not set, the transformed resource's target path will be the original path of the asset file with its extension replaced by `.css`.
|
||||
@@ -141,8 +141,8 @@ To install Dart Sass for your builds on GitLab Pages, the `.gitlab-ci.yml` file
|
||||
|
||||
```yaml
|
||||
variables:
|
||||
HUGO_VERSION: 0.128.0
|
||||
DART_SASS_VERSION: 1.77.5
|
||||
HUGO_VERSION: 0.137.1
|
||||
DART_SASS_VERSION: 1.80.6
|
||||
GIT_DEPTH: 0
|
||||
GIT_STRATEGY: clone
|
||||
GIT_SUBMODULE_STRATEGY: recursive
|
||||
@@ -175,8 +175,8 @@ To install Dart Sass for your builds on Netlify, the `netlify.toml` file should
|
||||
|
||||
```toml
|
||||
[build.environment]
|
||||
HUGO_VERSION = "0.128.0"
|
||||
DART_SASS_VERSION = "1.77.5"
|
||||
HUGO_VERSION = "0.137.1"
|
||||
DART_SASS_VERSION = "1.80.6"
|
||||
TZ = "America/Los_Angeles"
|
||||
|
||||
[build]
|
||||
|
@@ -16,7 +16,7 @@ toc: true
|
||||
|
||||
{{< new-in 0.128.0 >}}
|
||||
|
||||
<!-- TODO remove this admonition when feature is stable. -->
|
||||
{{% todo %}}remove this admonition when feature is stable.{{% /todo %}}
|
||||
|
||||
{{% note %}}
|
||||
This is an experimental feature pending the release of TailwindCSS v4.0.
|
||||
@@ -31,9 +31,10 @@ To use this function you must install the Tailwind CSS CLI v4.0 or later. You ma
|
||||
[Tailwind CSS documentation]: https://tailwindcss.com/docs/installation
|
||||
|
||||
{{% note %}}
|
||||
Use npm to install the CLI prior to the v4.0 release of Tailwind CSS.
|
||||
Prior to the release of Tailwind CSS v4.0 you must install [v4.0.0-alpha.26](https://github.com/tailwindlabs/tailwindcss/releases/tag/v4.0.0-alpha.26) or later.
|
||||
|
||||
`npm install --save-dev tailwindcss@next @tailwindcss/cli@next`
|
||||
|
||||
{{% /note %}}
|
||||
|
||||
## Options
|
||||
@@ -54,7 +55,7 @@ skipInlineImportsNotFound
|
||||
|
||||
Define a [cache buster] in your site configuration:
|
||||
|
||||
[cache buster]: /getting-started/configuration/#configure-cache-busters
|
||||
[cache buster]: /getting-started/configuration-build/#configure-cache-busters
|
||||
|
||||
{{< code-toggle file=hugo >}}
|
||||
[[build.cachebusters]]
|
||||
|
@@ -11,5 +11,5 @@ action:
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
{{ hugo.Generator }} → <meta name="generator" content="Hugo 0.128.0">
|
||||
{{ hugo.Generator }} → <meta name="generator" content="Hugo 0.137.1">
|
||||
```
|
||||
|
@@ -11,5 +11,5 @@ action:
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
{{ hugo.Version }} → 0.128.0
|
||||
{{ hugo.Version }} → 0.137.1
|
||||
```
|
||||
|
@@ -15,9 +15,9 @@ expiryDate: 2025-06-24 # deprecated 2024-06-24
|
||||
---
|
||||
|
||||
{{% deprecated-in 0.128.0 %}}
|
||||
Use [js.Babel] instead.
|
||||
Use [`js.Babel`] instead.
|
||||
|
||||
[js.Babel]: /functions/js/babel/
|
||||
[`js.Babel`]: /functions/js/babel/
|
||||
{{% /deprecated-in %}}
|
||||
|
||||
```go-html-template
|
||||
|
@@ -24,7 +24,7 @@ Let's say you need to publish a file named "site.json" in the root of your publi
|
||||
```json
|
||||
{
|
||||
"build_date": "2024-02-19T12:27:05-08:00",
|
||||
"hugo_version": "0.128.0",
|
||||
"hugo_version": "0.137.1",
|
||||
"last_modified": "2024-02-19T12:01:42-08:00"
|
||||
}
|
||||
```
|
||||
|
@@ -102,6 +102,10 @@ The [`Err`] method on a resource returned by the `resources.GetRemote` function
|
||||
|
||||
[`Err`]: /methods/resource/err/
|
||||
|
||||
{{% note %}}
|
||||
Hugo does not classify an HTTP response with status code 404 as an error. In this case the function returns nil.
|
||||
{{% /note %}}
|
||||
|
||||
```go-html-template
|
||||
{{ $url := "https://broken-example.org/images/a.jpg" }}
|
||||
{{ with resources.GetRemote $url }}
|
||||
|
@@ -16,9 +16,9 @@ expiryDate: 2025-06-24 # deprecated 2024-06-24
|
||||
---
|
||||
|
||||
{{% deprecated-in 0.128.0 %}}
|
||||
Use [css.PostCSS] instead.
|
||||
Use [`css.PostCSS`] instead.
|
||||
|
||||
[css.PostCSS]: /functions/css/postcss/
|
||||
[`css.PostCSS`]: /functions/css/postcss/
|
||||
{{% /deprecated-in %}}
|
||||
|
||||
```go-html-template
|
||||
|
@@ -16,9 +16,9 @@ expiryDate: 2025-06-24 # deprecated 2024-06-24
|
||||
---
|
||||
|
||||
{{% deprecated-in 0.128.0 %}}
|
||||
Use [css.Sass] instead.
|
||||
Use [`css.Sass`] instead.
|
||||
|
||||
[css.Sass]: /functions/css/sass/
|
||||
[`css.Sass`]: /functions/css/sass/
|
||||
{{% /deprecated-in %}}
|
||||
|
||||
```go-html-template
|
||||
@@ -36,7 +36,7 @@ Use [css.Sass] instead.
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
Transpile Sass to CSS using the LibSass transpiler included in Hugo's extended edition, or [install Dart Sass](#dart-sass) to use the latest features of the Sass language.
|
||||
Transpile Sass to CSS using the LibSass transpiler included in Hugo's extended and extended/deploy editions, or [install Dart Sass](#dart-sass) to use the latest features of the Sass language.
|
||||
|
||||
Sass has two forms of syntax: [SCSS] and [indented]. Hugo supports both.
|
||||
|
||||
@@ -46,7 +46,7 @@ Sass has two forms of syntax: [SCSS] and [indented]. Hugo supports both.
|
||||
## Options
|
||||
|
||||
transpiler
|
||||
: (`string`) The transpiler to use, either `libsass` (default) or `dartsass`. Hugo's extended edition includes the LibSass transpiler. To use the Dart Sass transpiler, see the [installation instructions](#dart-sass) below.
|
||||
: (`string`) The transpiler to use, either `libsass` (default) or `dartsass`. Hugo's extended and extended/deploy editions include the LibSass transpiler. To use the Dart Sass transpiler, see the [installation instructions](#dart-sass) below.
|
||||
|
||||
targetPath
|
||||
: (`string`) If not set, the transformed resource's target path will be the original path of the asset file with its extension replaced by `.css`.
|
||||
@@ -145,8 +145,8 @@ To install Dart Sass for your builds on GitLab Pages, the `.gitlab-ci.yml` file
|
||||
|
||||
```yaml
|
||||
variables:
|
||||
HUGO_VERSION: 0.128.0
|
||||
DART_SASS_VERSION: 1.77.5
|
||||
HUGO_VERSION: 0.137.1
|
||||
DART_SASS_VERSION: 1.80.6
|
||||
GIT_DEPTH: 0
|
||||
GIT_STRATEGY: clone
|
||||
GIT_SUBMODULE_STRATEGY: recursive
|
||||
@@ -179,8 +179,8 @@ To install Dart Sass for your builds on Netlify, the `netlify.toml` file should
|
||||
|
||||
```toml
|
||||
[build.environment]
|
||||
HUGO_VERSION = "0.128.0"
|
||||
DART_SASS_VERSION = "1.77.5"
|
||||
HUGO_VERSION = "0.137.1"
|
||||
DART_SASS_VERSION = "1.80.6"
|
||||
TZ = "America/Los_Angeles"
|
||||
|
||||
[build]
|
||||
|
@@ -7,6 +7,7 @@ action:
|
||||
aliases: [chomp]
|
||||
related:
|
||||
- functions/strings/Trim
|
||||
- functions/strings/TrimSpace
|
||||
- functions/strings/TrimLeft
|
||||
- functions/strings/TrimPrefix
|
||||
- functions/strings/TrimRight
|
||||
@@ -19,9 +20,9 @@ aliases: [/functions/chomp]
|
||||
If the argument is of type `template.HTML`, returns `template.HTML`, else returns a `string`.
|
||||
|
||||
```go-html-template
|
||||
{{ chomp | "foo\n" }} → foo
|
||||
{{ chomp | "foo\n\n" }} → foo
|
||||
{{ chomp "foo\n" }} → foo
|
||||
{{ chomp "foo\n\n" }} → foo
|
||||
|
||||
{{ chomp | "foo\r\n" }} → foo
|
||||
{{ chomp | "foo\r\n\r\n" }} → foo
|
||||
{{ chomp "foo\r\n" }} → foo
|
||||
{{ chomp "foo\r\n\r\n" }} → foo
|
||||
```
|
||||
|
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: strings.ContainsNonSpace
|
||||
description: Reports whether the given string contains any non-space characters as defined by Unicode's White Space property.
|
||||
description: Reports whether the given string contains any non-space characters as defined by Unicode.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
@@ -18,18 +18,12 @@ aliases: [/functions/strings.containsnonspace]
|
||||
|
||||
{{< new-in 0.111.0 >}}
|
||||
|
||||
Whitespace characters include `\t`, `\n`, `\v`, `\f`, `\r`, and characters in the [Unicode Space Separator] category.
|
||||
|
||||
[Unicode Space Separator]: https://www.compart.com/en/unicode/category/Zs
|
||||
|
||||
```go-html-template
|
||||
{{ strings.ContainsNonSpace "\n" }} → false
|
||||
{{ strings.ContainsNonSpace " " }} → false
|
||||
{{ strings.ContainsNonSpace "\n abc" }} → true
|
||||
```
|
||||
|
||||
Common whitespace characters include:
|
||||
|
||||
```text
|
||||
'\t', '\n', '\v', '\f', '\r', ' '
|
||||
```
|
||||
|
||||
See the [Unicode Character Database] for a complete list.
|
||||
|
||||
[Unicode Character Database]: https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
|
||||
|
@@ -7,6 +7,7 @@ action:
|
||||
aliases: [trim]
|
||||
related:
|
||||
- functions/strings/Chomp
|
||||
- functions/strings/TrimSpace
|
||||
- functions/strings/TrimLeft
|
||||
- functions/strings/TrimPrefix
|
||||
- functions/strings/TrimRight
|
||||
@@ -19,41 +20,3 @@ aliases: [/functions/trim]
|
||||
```go-html-template
|
||||
{{ trim "++foo--" "+-" }} → foo
|
||||
```
|
||||
|
||||
To remove leading and trailing newline characters and carriage returns:
|
||||
|
||||
```go-html-template
|
||||
{{ trim "\nfoo\n" "\n\r" }} → foo
|
||||
{{ trim "\n\nfoo\n\n" "\n\r" }} → foo
|
||||
|
||||
{{ trim "\r\nfoo\r\n" "\n\r" }} → foo
|
||||
{{ trim "\r\n\r\nfoo\r\n\r\n" "\n\r" }} → foo
|
||||
```
|
||||
|
||||
The `strings.Trim` function is commonly used in shortcodes to remove leading and trailing newlines characters and carriage returns from the content within the opening and closing shortcode tags.
|
||||
|
||||
For example, with this Markdown:
|
||||
|
||||
```text
|
||||
{{</* my-shortcode */>}}
|
||||
Able was I ere I saw Elba.
|
||||
{{</* /my-shortcode */>}}
|
||||
```
|
||||
|
||||
The value of `.Inner` in the shortcode template is:
|
||||
|
||||
```text
|
||||
\nAble was I ere I saw Elba.\n
|
||||
```
|
||||
|
||||
If authored on a Windows system the value of `.Inner` might, depending on the editor configuration, be:
|
||||
|
||||
```text
|
||||
\r\nAble was I ere I saw Elba.\r\n
|
||||
```
|
||||
|
||||
This construct is common in shortcode templates:
|
||||
|
||||
```go-html-template
|
||||
{{ trim .Inner "\n\r" }}
|
||||
```
|
||||
|
@@ -8,6 +8,7 @@ action:
|
||||
related:
|
||||
- functions/strings/Chomp
|
||||
- functions/strings/Trim
|
||||
- functions/strings/TrimSpace
|
||||
- functions/strings/TrimPrefix
|
||||
- functions/strings/TrimRight
|
||||
- functions/strings/TrimSuffix
|
||||
|
@@ -8,6 +8,7 @@ action:
|
||||
related:
|
||||
- functions/strings/Chomp
|
||||
- functions/strings/Trim
|
||||
- functions/strings/TrimSpace
|
||||
- functions/strings/TrimLeft
|
||||
- functions/strings/TrimRight
|
||||
- functions/strings/TrimSuffix
|
||||
|
@@ -8,6 +8,7 @@ action:
|
||||
related:
|
||||
- functions/strings/Chomp
|
||||
- functions/strings/Trim
|
||||
- functions/strings/TrimSpace
|
||||
- functions/strings/TrimLeft
|
||||
- functions/strings/TrimPrefix
|
||||
- functions/strings/TrimSuffix
|
||||
|
26
docs/content/en/functions/strings/TrimSpace.md
Normal file
26
docs/content/en/functions/strings/TrimSpace.md
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
title: strings.TrimSpace
|
||||
description: Returns the given string, removing leading and trailing whitespace as defined by Unicode.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/strings/Chomp
|
||||
- functions/strings/Trim
|
||||
- functions/strings/TrimLeft
|
||||
- functions/strings/TrimPrefix
|
||||
- functions/strings/TrimRight
|
||||
- functions/strings/TrimSuffix
|
||||
returnType: string
|
||||
signatures: [strings.TrimSpace INPUT]
|
||||
---
|
||||
|
||||
{{< new-in 0.136.3 >}}
|
||||
|
||||
Whitespace characters include `\t`, `\n`, `\v`, `\f`, `\r`, and characters in the [Unicode Space Separator] category.
|
||||
|
||||
[Unicode Space Separator]: https://www.compart.com/en/unicode/category/Zs
|
||||
|
||||
```go-html-template
|
||||
{{ strings.TrimSpace "\n\r\t foo \n\r\t" }} → foo
|
||||
```
|
@@ -8,6 +8,7 @@ action:
|
||||
related:
|
||||
- functions/strings/Chomp
|
||||
- functions/strings/Trim
|
||||
- functions/strings/TrimSpace
|
||||
- functions/strings/TrimLeft
|
||||
- functions/strings/TrimPrefix
|
||||
- functions/strings/TrimRight
|
||||
|
@@ -21,41 +21,34 @@ toc: true
|
||||
Hugo provides [functions] and [methods] to format, localize, parse, compare, and manipulate date/time values. Before you can do any of these with string representations of date/time values, you must first convert them to [`time.Time`] values using the `time.AsTime` function.
|
||||
|
||||
```go-html-template
|
||||
{{ $t := "2023-10-15T14:20:28-07:00" }}
|
||||
{{ time.AsTime $t }} → 2023-10-15 14:20:28 -0700 PDT (time.Time)
|
||||
{{ $t := "2023-10-15T13:18:50-07:00" }}
|
||||
{{ time.AsTime $t }} → 2023-10-15 13:18:50 -0700 PDT (time.Time)
|
||||
```
|
||||
|
||||
## Parsable strings
|
||||
|
||||
As shown above, the first argument must be a *parsable* string representation of a date/time value. For example:
|
||||
As shown above, the first argument must be a parsable string representation of a date/time value. For example:
|
||||
|
||||
{{% include "functions/time/_common/parsable-date-time-strings.md" %}}
|
||||
|
||||
## Time zones
|
||||
To override the default time zone, set the [`timeZone`] in your site configuration or provide a second argument to the `time.AsTime` function. For example:
|
||||
|
||||
When the parsable string does not contain a time zone offset, you can do either of the following to assign a time zone other than Etc/UTC:
|
||||
```go-html-template
|
||||
{{ time.AsTime "15 Oct 2023" "America/Los_Angeles" }}
|
||||
```
|
||||
|
||||
- Provide a second argument to the `time.AsTime` function
|
||||
|
||||
```go-html-template
|
||||
{{ time.AsTime "15 Oct 2023" "America/Chicago" }}
|
||||
```
|
||||
|
||||
- Set the default time zone in your site configuration
|
||||
|
||||
{{< code-toggle file=hugo >}}
|
||||
timeZone = 'America/New_York'
|
||||
{{< /code-toggle >}}
|
||||
The list of valid time zones may be system dependent, but should include `UTC`, `Local`, or any location in the [IANA Time Zone database].
|
||||
|
||||
The order of precedence for determining the time zone is:
|
||||
|
||||
1. The time zone offset in the date/time string
|
||||
2. The time zone provide as the second argument to the `time.AsTime` function
|
||||
2. The time zone provided as the second argument to the `time.AsTime` function
|
||||
3. The time zone specified in your site configuration
|
||||
4. The `Etc/UTC` time zone
|
||||
|
||||
The list of valid time zones may be system dependent, but should include `UTC`, `Local`, or any location in the [IANA Time Zone database].
|
||||
|
||||
[IANA Time Zone database]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
[`time.Time`]: https://pkg.go.dev/time#Time
|
||||
[`timeZone`]: https://gohugo.io/getting-started/configuration/#timezone
|
||||
[functions]: /functions/time/
|
||||
[iana time zone database]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
[methods]: /methods/time/
|
||||
|
@@ -19,21 +19,29 @@ toc: true
|
||||
Use the `time.Format` function with `time.Time` values:
|
||||
|
||||
```go-html-template
|
||||
{{ $t := time.AsTime "2023-02-27T23:44:58-08:00" }}
|
||||
{{ time.Format "2 Jan 2006" $t }} → 27 Feb 2023
|
||||
{{ $t := time.AsTime "2023-10-15T13:18:50-07:00" }}
|
||||
{{ time.Format "2 Jan 2006" $t }} → 15 Oct 2023
|
||||
```
|
||||
|
||||
Or use `time.Format` with a *parsable* string representation of a date/time value:
|
||||
Or use `time.Format` with a parsable string representation of a date/time value:
|
||||
|
||||
```go-html-template
|
||||
{{ $t := "27 Feb 2023" }}
|
||||
{{ time.Format "January 2, 2006" $t }} → February 27, 2023
|
||||
{{ $t := "15 Oct 2023" }}
|
||||
{{ time.Format "January 2, 2006" $t }} → October 15, 2023
|
||||
```
|
||||
|
||||
Examples of parsable string representations:
|
||||
|
||||
{{% include "functions/time/_common/parsable-date-time-strings.md" %}}
|
||||
|
||||
To override the default time zone, set the [`timeZone`] in your site configuration. The order of precedence for determining the time zone is:
|
||||
|
||||
1. The time zone offset in the date/time string
|
||||
2. The time zone specified in your site configuration
|
||||
3. The `Etc/UTC` time zone
|
||||
|
||||
[`timeZone`]: https://gohugo.io/getting-started/configuration/#timezone
|
||||
|
||||
## Layout string
|
||||
|
||||
{{% include "functions/_common/time-layout-string.md" %}}
|
||||
|
@@ -2,13 +2,13 @@
|
||||
# Do not remove front matter.
|
||||
---
|
||||
|
||||
String representation|Time zone
|
||||
Format|Time zone
|
||||
:--|:--
|
||||
2023-10-15T14:20:28-07:00|America/Los_Angeles
|
||||
2023-10-15T13:18:50-0700|America/Los_Angeles
|
||||
2023-10-15T13:18:50Z|Etc/UTC
|
||||
2023-10-15T13:18:50|Etc/UTC
|
||||
2023-10-15|Etc/UTC
|
||||
15 Oct 2023|Etc/UTC
|
||||
`2023-10-15T13:18:50-07:00`|`America/Los_Angeles`
|
||||
`2023-10-15T13:18:50-0700`|`America/Los_Angeles`
|
||||
`2023-10-15T13:18:50Z`|`Etc/UTC`
|
||||
`2023-10-15T13:18:50`|Default is `Etc/UTC`
|
||||
`2023-10-15`|Default is `Etc/UTC`
|
||||
`15 Oct 2023`|Default is `Etc/UTC`
|
||||
|
||||
The last four examples are not fully qualified. Without a time zone offset, the time zone is set to Etc/UTC (Coordinated Universal Time).
|
||||
The last three examples are not fully qualified, and default to the `Etc/UTC` time zone.
|
||||
|
@@ -2,7 +2,7 @@
|
||||
title: transform.ToMath
|
||||
description: Renders a math expression using KaTeX.
|
||||
categories: []
|
||||
keywords: []
|
||||
keywords: [math,katex]
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
@@ -36,7 +36,7 @@ These are a subset of the [KaTeX options].
|
||||
output
|
||||
: (`string`). Determines the markup language of the output. One of `html`, `mathml`, or `htmlAndMathml`. Default is `mathml`.
|
||||
|
||||
<!-- Indent to prevent spliting the description list. -->
|
||||
{{% comment %}}Indent to prevent splitting the description list.{{% / comment %}}
|
||||
|
||||
With `html` and `htmlAndMathml` you must include KaTeX CSS within the `head` element of your base template. For example:
|
||||
|
||||
@@ -94,7 +94,7 @@ There are 3 ways to handle errors from KaTeX:
|
||||
|
||||
1. Let KaTeX throw an error and make the build fail. This is the default behavior.
|
||||
1. Handle the error in your template. See the render hook example below.
|
||||
1. Set the `throwOnError` option to `false` to make KaTeX render the expression as an error instead of throwing an error. See [options].
|
||||
1. Set the `throwOnError` option to `false` to make KaTeX render the expression as an error instead of throwing an error. See [options](#options).
|
||||
|
||||
{{< code file=layouts/_default/_markup/render-passthrough-inline.html copy=true >}}
|
||||
{{ with transform.ToMath .Inner }}
|
||||
|
Reference in New Issue
Block a user