markdown

package
v1.21.32 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DocumentVersion = 1

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	Version  int            `json:"version"`
	Filename string         `json:"filename,omitempty"`
	Metadata map[string]any `json:"metadata,omitempty"`
	Root     Node           `json:"root"`
}

Document is a parsed markdown document that can render through Clicky's Textable formats and export as structured Clicky document JSON.

func Parse

func Parse(source []byte, opts ...Option) (*Document, error)

Parse parses markdown source into a structured Clicky markdown document.

func ParseFile

func ParseFile(filename string, opts ...Option) (*Document, error)

ParseFile reads and parses a markdown file.

func ParseString

func ParseString(source string, opts ...Option) (*Document, error)

ParseString parses markdown source into a structured Clicky markdown document.

func (*Document) ANSI

func (d *Document) ANSI() string

func (*Document) ClickyDocument

func (d *Document) ClickyDocument() formatters.ClickyDocument

ClickyDocument exports the parsed tree using the same JSON envelope consumed by @flanksource/clicky-ui.

func (*Document) HTML

func (d *Document) HTML() string

func (*Document) Markdown

func (d *Document) Markdown() string

func (*Document) String

func (d *Document) String() string

type Node

type Node struct {
	Kind       string            `json:"kind"`
	Text       string            `json:"text,omitempty"`
	Children   []Node            `json:"children,omitempty"`
	Items      []Node            `json:"items,omitempty"`
	Attributes map[string]string `json:"attributes,omitempty"`
	Level      int               `json:"level,omitempty"`
	Language   string            `json:"language,omitempty"`
	Source     string            `json:"source,omitempty"`
	RawHTML    string            `json:"html,omitempty"`
	Href       string            `json:"href,omitempty"`
	Title      string            `json:"title,omitempty"`
	ID         string            `json:"id,omitempty"`
	Severity   string            `json:"severity,omitempty"`
	Checked    *bool             `json:"checked,omitempty"`
	Ordered    bool              `json:"ordered,omitempty"`
	Align      string            `json:"align,omitempty"`
	LineStart  int               `json:"lineStart,omitempty"`
	LineEnd    int               `json:"lineEnd,omitempty"`
}

Node is the intermediate semantic tree produced from Goldmark's AST.

func (Node) ANSI

func (n Node) ANSI() string

func (Node) ClickyNode

func (n Node) ClickyNode() formatters.ClickyNode

ClickyNode converts the markdown node to Clicky's concrete document JSON node.

func (Node) HTML

func (n Node) HTML() string

func (Node) Markdown

func (n Node) Markdown() string

func (Node) String

func (n Node) String() string

type Option

type Option func(*Options)

Option configures markdown parsing.

func WithAdmonitions

func WithAdmonitions(enabled bool) Option

WithAdmonitions enables or disables pragmatic "!!! severity title" parsing.

func WithFilename

func WithFilename(filename string) Option

WithFilename records the source filename in the parsed document metadata.

func WithFootnotes

func WithFootnotes(enabled bool) Option

WithFootnotes enables or disables footnote parsing.

func WithFrontmatter

func WithFrontmatter(enabled bool) Option

WithFrontmatter enables or disables leading YAML frontmatter extraction.

func WithGFM

func WithGFM(enabled bool) Option

WithGFM enables or disables GitHub Flavored Markdown extensions.

func WithPreserveHTML

func WithPreserveHTML(enabled bool) Option

WithPreserveHTML controls whether raw HTML nodes are retained.

func WithSourceSpans

func WithSourceSpans(enabled bool) Option

WithSourceSpans controls whether line start/end metadata is attached to nodes.

type Options

type Options struct {
	Filename     string
	GFM          bool
	Footnotes    bool
	Frontmatter  bool
	Admonitions  bool
	PreserveHTML bool
	SourceSpans  bool
}

Options controls how markdown source is parsed and preserved.

Jump to

Keyboard shortcuts

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