| 1 |
--- |
| 2 |
title: transform.HTMLToMarkdown |
| 3 |
description: Returns the given HTML converted to Markdown. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
returnType: string |
| 9 |
signatures: [transform.HTMLToMarkdown INPUT] |
| 10 |
--- |
| 11 |
|
| 12 |
{{< new-in 0.151.0 />}} |
| 13 |
|
| 14 |
> [!NOTE] |
| 15 |
> This function is experimental and its API may change in the future. |
| 16 |
|
| 17 |
The `transform.HTMLToMarkdown` function converts HTML to Markdown by utilizing the [`html-to-markdown`][] Go package. |
| 18 |
|
| 19 |
## Usage |
| 20 |
|
| 21 |
```go-html-template |
| 22 |
{{ .Content | transform.HTMLToMarkdown | safeHTML }} |
| 23 |
``` |
| 24 |
|
| 25 |
## Plugins |
| 26 |
|
| 27 |
The conversion process is enabled by the following `html-to-markdown` plugins: |
| 28 |
|
| 29 |
Plugin|Description |
| 30 |
:--|:-- |
| 31 |
Base|Implements basic shared functionality |
| 32 |
CommonMark|Implements Markdown according to the [Commonmark][] specification |
| 33 |
Table|Implements tables according to the [GitHub Flavored Markdown][] specification |
| 34 |
|
| 35 |
[Commonmark]: https://spec.commonmark.org/current/ |
| 36 |
[GitHub Flavored Markdown]: https://github.github.com/gfm/ |
| 37 |
[`html-to-markdown`]: https://github.com/JohannesKaufmann/html-to-markdown?tab=readme-ov-file#readme |