markdown

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator struct {
	ImageBasePath string // Base path for image references (e.g., "images")
	EscapeHTML    bool   // Whether to escape HTML characters (default: false)
}

Generator converts structured document data to CommonMark-compatible Markdown. It formats headings, paragraphs, tables, images, lists, and links according to the CommonMark 0.30 specification.

func NewGenerator

func NewGenerator(imageBasePath string) *Generator

NewGenerator creates a new Markdown generator with the specified image base path. The imageBasePath is used to construct relative paths for image references in the generated Markdown.

func (*Generator) Generate

func (g *Generator) Generate(data *types.DocumentData) (string, error)

Generate converts document data to a Markdown string. Elements are formatted in the order they appear in the document data. If Elements is populated, it preserves document order. Otherwise, it falls back to processing by type (headings, then paragraphs, then tables, etc.). The output follows CommonMark 0.30 specification and is well-formatted with appropriate spacing between elements.

Jump to

Keyboard shortcuts

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