mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-10 03:54:58 -04:00
parent
afb582a800
commit
d54185beff
@ -1,10 +1,7 @@
|
|||||||
---
|
---
|
||||||
title: markdownify
|
title: markdownify
|
||||||
linktitle: markdownify
|
linktitle: markdownify
|
||||||
description: Runs the provided string through the Markdown processor.
|
description: Renders markdown to HTML.
|
||||||
date: 2017-02-01
|
|
||||||
publishdate: 2017-02-01
|
|
||||||
lastmod: 2023-02-09
|
|
||||||
keywords: [markdown,content]
|
keywords: [markdown,content]
|
||||||
categories: [functions]
|
categories: [functions]
|
||||||
menu:
|
menu:
|
||||||
@ -18,12 +15,21 @@ deprecated: false
|
|||||||
aliases: []
|
aliases: []
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
{{ .Title | markdownify }}
|
{{ .Title | markdownify }}
|
||||||
```
|
```
|
||||||
|
|
||||||
{{< new-in "0.93.0" >}} **Note**: `markdownify` now supports [Render Hooks] just like [`.Page.RenderString`]. However, if you use more complicated [Render Hooks] relying on page context, use [`.Page.RenderString`] instead. See [GitHub issue #9692](https://github.com/gohugoio/hugo/issues/9692) for more details.
|
If the resulting HTML is a single paragraph, Hugo removes the wrapping `p` tags to produce inline HTML as required per the example above.
|
||||||
|
|
||||||
|
To keep the wrapping `p` tags for a single paragraph, use the [`.Page.RenderString`] method, setting the `display` option to `block`.
|
||||||
|
|
||||||
|
If the resulting HTML is two or more paragraphs, Hugo leaves the wrapping `p` tags in place.
|
||||||
|
|
||||||
[Render Hooks]: /templates/render-hooks/
|
|
||||||
[`.Page.RenderString`]: /functions/renderstring/
|
[`.Page.RenderString`]: /functions/renderstring/
|
||||||
|
|
||||||
|
{{% note %}}
|
||||||
|
Although the `markdownify` function honors [markdown render hooks] when rendering markdown to HTML, use the `.Page.RenderString` method instead of `markdownify` if a render hook accesses `.Page` context. See issue [#9692] for details.
|
||||||
|
|
||||||
|
[markdown render hooks]: /templates/render-hooks/
|
||||||
|
[#9692]: https://github.com/gohugoio/hugo/issues/9692
|
||||||
|
{{% /note %}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user