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 ¶
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.