File: HTMLtoMarkdown.md

package info (click to toggle)
hugo 0.155.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 43,600 kB
  • sloc: javascript: 31,879; ansic: 2,350; xml: 350; makefile: 196; sh: 110
file content (37 lines) | stat: -rw-r--r-- 1,056 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---
title: transform.HTMLToMarkdown
description: Converts HTML to Markdown.
categories: []
keywords: []
params:
  functions_and_methods:
    returnType: string
    signatures: [transform.HTMLToMarkdown INPUT]
---

{{< new-in "0.151.0" />}}

> [!note]
> This function is experimental and its API may change in the future.

The `transform.HTMLToMarkdown` function converts HTML to Markdown by utilizing the [`html-to-markdown`][] Go package.

## Usage

```go-html-template
{{ .Content | transform.HTMLToMarkdown | safeHTML }}
```

## Plugins

The conversion process is enabled by the following `html-to-markdown` plugins:

Plugin|Description
:--|:--
Base|Implements basic shared functionality
CommonMark|Implements Markdown according to the [Commonmark Spec][]
Table|Implements tables according to the [GitHub Flavored Markdown Spec][]

[`html-to-markdown`]: https://github.com/JohannesKaufmann/html-to-markdown?tab=readme-ov-file#readme
[Commonmark Spec]: https://spec.commonmark.org/current/
[GitHub Flavored Markdown Spec]: https://github.github.com/gfm/