Documentation
¶
Overview ¶
Package formatter provides formatting functionality for markdown nodes.
Index ¶
Constants ¶
const ( // HeadingFormatterPriority defines the priority for heading formatting (higher runs first) HeadingFormatterPriority = 100 // ParagraphFormatterPriority defines the priority for paragraph formatting ParagraphFormatterPriority = 90 // ListFormatterPriority defines the priority for list formatting ListFormatterPriority = 80 // CodeFormatterPriority defines the priority for code block formatting CodeFormatterPriority = 70 // WhitespaceFormatterPriority defines the priority for whitespace formatting (lowest) WhitespaceFormatterPriority = 10 // InlineFormatterPriority defines the priority for inline formatting InlineFormatterPriority = 60 // AtxHeadingStyle represents ATX-style heading format (# ## ###) AtxHeadingStyle = "atx" // SetextHeadingStyle represents setext-style heading format (underlined with = or -) SetextHeadingStyle = "setext" // MinHeadingLevel defines the minimum allowed heading level MinHeadingLevel = 1 // MaxHeadingLevel defines the maximum allowed heading level MaxHeadingLevel = 6 // SetextMaxLevel defines the maximum level for setext-style headings SetextMaxLevel = 2 )
Constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseFormatter ¶
type BaseFormatter struct {
// contains filtered or unexported fields
}
BaseFormatter provides common functionality for formatters
func (*BaseFormatter) Priority ¶
func (f *BaseFormatter) Priority() int
Priority returns the formatter priority
type CodeBlockFormatter ¶
type CodeBlockFormatter struct {
BaseFormatter
}
CodeBlockFormatter formats code block nodes
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine represents the main formatting engine
func (*Engine) Register ¶
func (e *Engine) Register(formatter NodeFormatter)
Register registers a new node formatter
func (*Engine) RegisterDefaults ¶
func (e *Engine) RegisterDefaults()
RegisterDefaults registers the default formatters
type Formatter ¶
type Formatter interface {
// Format formats the given AST according to configuration
Format(root parser.Node, cfg *config.Config) error
}
Formatter represents a markdown formatter interface
type HeadingFormatter ¶
type HeadingFormatter struct {
BaseFormatter
}
HeadingFormatter formats heading nodes
func NewHeadingFormatter ¶
func NewHeadingFormatter() *HeadingFormatter
NewHeadingFormatter creates a new heading formatter
type InlineFormatter ¶
type InlineFormatter struct {
BaseFormatter
}
InlineFormatter handles inline elements like links, emphasis, and inline code
func NewInlineFormatter ¶
func NewInlineFormatter() *InlineFormatter
NewInlineFormatter creates a new inline formatter
type ListFormatter ¶
type ListFormatter struct {
BaseFormatter
}
ListFormatter formats list nodes
type NodeFormatter ¶
type NodeFormatter interface {
// Name returns the name of the formatter
Name() string
// CanFormat returns true if this formatter can handle the given node type
CanFormat(nodeType parser.NodeType) bool
// Format formats a specific node
Format(node parser.Node, cfg *config.Config) error
// Priority returns the priority of this formatter (higher = earlier)
Priority() int
}
NodeFormatter represents a formatter for specific node types
type ParagraphFormatter ¶
type ParagraphFormatter struct {
BaseFormatter
}
ParagraphFormatter formats paragraph nodes
type WhitespaceFormatter ¶
type WhitespaceFormatter struct {
BaseFormatter
}
WhitespaceFormatter handles whitespace normalization