format

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2024 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

package format (markdown) is a markdown to html converter, heavily inspired by the mautrix-go/format package

Index

Constants

This section is empty.

Variables

View Source
var (
	// Extensions is the default set of extensions to use with Goldmark.
	Extensions = goldmark.WithExtensions(extension.Strikethrough, extension.Table)
	// RendererOptions is the default set of renderer options to use with Goldmark.
	RendererOptions = goldmark.WithRendererOptions(html.WithHardWraps(), html.WithUnsafe())
	// ParserOptions is the default set of parser options to use with Goldmark.
	ParserOptions = goldmark.WithParserOptions(parser.WithASTTransformers(util.Prioritized(&LinksTransformer{}, 1000)))

	// Renderer is the default Goldmark renderer.
	Renderer = goldmark.New(Extensions, RendererOptions, ParserOptions)
)

Functions

func Render

func Render(markdown string) (htmlString string)

Render renders the given markdown to HTML.

Types

type LinksTransformer

type LinksTransformer struct{}

LinksTransformer is a transformer that adds target="_blank" to all links.

func (*LinksTransformer) Transform

func (t *LinksTransformer) Transform(node *ast.Document, _ text.Reader, _ parser.Context)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL