markdown

Converts an HTML string to Markdown, so a fetched page or a rich-text field can be reduced to plain prose a later step can store or render.

It ships as a stub that returns an error until you inject a converter. A full HTML-to-Markdown converter is a heavy dependency, and the core stays free of third-party dependencies rather than forcing one on every consumer. Injecting one is a map entry.

func toMarkdown(html string) (string, error) {
	return htmltomarkdown.ConvertString(html)
}

mods := serialize.Modifiers()
mods[string(serialize.ModifierNameMarkdown)] = functions.Wrap(toMarkdown)
out, err := sintax.New(mods).Render(tpl, vars)
InputArgumentsReturnsstringno argumentsstring
Source
BasicSource

Converts HTML to Markdown once a converter is injected, so a rich-text field can be reduced to plain prose.

Given

{"body": "<h1>Title</h1><p>Some <strong>bold</strong> prose.</p>"}

Template

{{ body | markdown }}

Result

# Title
Some **bold** prose.