goldmark – github.com/yuin/goldmark Index | Files | Directories

package goldmark

import "github.com/yuin/goldmark"

Package goldmark implements functions to convert markdown text to a desired format.

Index

Functions

func Convert

func Convert(source []byte, w io.Writer, opts ...parser.ParseOption) error

Convert interprets a UTF-8 bytes source in Markdown and write rendered contents to a writer w.

func DefaultParser

func DefaultParser() parser.Parser

DefaultParser returns a new Parser that is configured by default values.

func DefaultRenderer

func DefaultRenderer() renderer.Renderer

DefaultRenderer returns a new Renderer that is configured by default values.

Types

type Extender

type Extender interface {
	// Extend extends the Markdown.
	Extend(Markdown)
}

An Extender interface is used for extending Markdown.

type Markdown

type Markdown interface {
	// Convert interprets a UTF-8 bytes source in Markdown and write rendered
	// contents to a writer w.
	Convert(source []byte, writer io.Writer, opts ...parser.ParseOption) error

	// Parser returns a Parser that will be used for conversion.
	Parser() parser.Parser

	// SetParser sets a Parser to this object.
	SetParser(parser.Parser)

	// Parser returns a Renderer that will be used for conversion.
	Renderer() renderer.Renderer

	// SetRenderer sets a Renderer to this object.
	SetRenderer(renderer.Renderer)
}

A Markdown interface offers functions to convert Markdown text to a desired format.

func New

func New(options ...Option) Markdown

New returns a new Markdown with given options.

type Option

type Option func(*markdown)

Option is a functional option type for Markdown objects.

func WithExtensions

func WithExtensions(ext ...Extender) Option

WithExtensions adds extensions.

func WithParser

func WithParser(p parser.Parser) Option

WithParser allows you to override the default parser.

func WithParserOptions

func WithParserOptions(opts ...parser.Option) Option

WithParserOptions applies options for the parser.

func WithRenderer

func WithRenderer(r renderer.Renderer) Option

WithRenderer allows you to override the default renderer.

func WithRendererOptions

func WithRendererOptions(opts ...renderer.Option) Option

WithRendererOptions applies options for the renderer.

Source Files

markdown.go

Directories

PathSynopsis
astPackage ast defines AST nodes that represent markdown elements.
_benchmark
_benchmark/cmark
extensionPackage extension is a collection of builtin extensions.
extension/astPackage ast defines AST nodes that represents extension's elements
fuzz
parserPackage parser contains stuff that are related to parsing a Markdown text.
rendererPackage renderer renders the given AST to certain formats.
renderer/htmlPackage html implements renderer that outputs HTMLs.
testutilPackage testutil provides utilities for unit tests.
textPackage text provides functionalities to manipulate texts.
_tools
utilPackage util provides utility functions for the goldmark.
Version
v1.7.8 (latest)
Published
Oct 16, 2024
Platform
linux/amd64
Imports
6 packages
Last checked
4 days ago

Tools for package owners.