markdown

package
v1.205.0 Latest Latest
Warning

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

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

Documentation

Overview

Package markdown provides custom markdown rendering with extended syntax support.

Index

Constants

View Source
const (
	DefaultLightGray      = "#e7e5e4" // Light gray for primary text.
	DefaultMidGray        = "#57534e" // Mid gray for secondary text.
	DefaultDarkGray       = "#030014" // Very dark gray (not used for backgrounds).
	DefaultCodeBackground = "#2F2E36" // Medium gray for code block backgrounds (from Fang) - RGB(47,46,54).
	DefaultCodeBgANSI256  = "236"     // ANSI256 color 236 = RGB(48,48,48) - closest to #2F2E36.
	DefaultPurple         = "#9B51E0" // Purple accent (existing Atmos purple).
	DefaultWhite          = "#FFFFFF" // White for emphasis.
)

Default color constants for code blocks.

Variables

View Source
var (
	White       = "#FFFFFF"
	Purple      = "#9B51E0"
	Blue        = "#00A3E0"
	Gray        = "#4A5568"
	Green       = "#48BB78"
	Yellow      = "#ECC94B"
	Red         = "#F56565"
	LightBlue   = "#4299E1"
	BlueLight   = "#63B3ED"
	GrayLight   = "#718096"
	GrayMid     = "#A0AEC0"
	GrayDark    = "#2D3748"
	GrayBorder  = "#CBD5E0"
	OffWhite    = "#F7FAFC"
	DarkSlate   = "#1A202C"
	GreenLight  = "#68D391"
	YellowLight = "#F6E05E"
	RedLight    = "#FC8181"
	MutedGray   = "#808080" // Gray for muted/subtle text (strikethrough restyle)
)

Base colors used throughout the application.

View Source
var Colors = struct {
	Primary    lipgloss.AdaptiveColor
	Secondary  lipgloss.AdaptiveColor
	Success    lipgloss.AdaptiveColor
	Warning    lipgloss.AdaptiveColor
	Error      lipgloss.AdaptiveColor
	Info       lipgloss.AdaptiveColor
	Subtle     lipgloss.AdaptiveColor
	HeaderBg   lipgloss.AdaptiveColor
	Border     lipgloss.AdaptiveColor
	Background lipgloss.AdaptiveColor
}{
	Primary:    lipgloss.AdaptiveColor{Light: Blue, Dark: Blue},
	Secondary:  lipgloss.AdaptiveColor{Light: Gray, Dark: GrayMid},
	Success:    lipgloss.AdaptiveColor{Light: Green, Dark: GreenLight},
	Warning:    lipgloss.AdaptiveColor{Light: Yellow, Dark: YellowLight},
	Error:      lipgloss.AdaptiveColor{Light: Red, Dark: RedLight},
	Info:       lipgloss.AdaptiveColor{Light: LightBlue, Dark: BlueLight},
	Subtle:     lipgloss.AdaptiveColor{Light: GrayLight, Dark: GrayMid},
	HeaderBg:   lipgloss.AdaptiveColor{Light: GrayDark, Dark: Gray},
	Border:     lipgloss.AdaptiveColor{Light: GrayBorder, Dark: Gray},
	Background: lipgloss.AdaptiveColor{Light: OffWhite, Dark: DarkSlate},
}

Colors defines the color scheme for markdown rendering.

Functions

func GetDefaultStyle

func GetDefaultStyle(atmosConfig schema.AtmosConfiguration) ([]byte, error)

GetDefaultStyle returns the markdown style configuration from atmos.yaml settings or falls back to built-in defaults if not configured.

func GetHelpStyle added in v1.200.0

func GetHelpStyle() ([]byte, error)

GetHelpStyle returns a markdown style configuration optimized for command help text. This uses the Cloud Posse color scheme (grayscale + purple accent) with transparent backgrounds.

func GetListIndentStyle added in v1.205.0

func GetListIndentStyle() ([]byte, error)

GetListIndentStyle returns a minimal style configuration with only list indentation settings. This is used for ASCII rendering to add list indentation without colors.

func RenderCodeBlock added in v1.200.0

func RenderCodeBlock(renderer *lipgloss.Renderer, content string, terminalWidth int) string

RenderCodeBlock renders a code block with Fang-style syntax highlighting. This avoids nested backgrounds by doing custom parsing instead of using Glamour. It follows Fang's approach: style content first, measure it, then apply background.

func SplitMarkdownContent

func SplitMarkdownContent(content string) []string

SplitMarkdownContent splits markdown content into details and suggestion parts.

Types

type CodeblockStyle added in v1.200.0

type CodeblockStyle struct {
	Base    lipgloss.Style
	Text    lipgloss.Style
	Comment lipgloss.Style
	Program lipgloss.Style
	Flag    lipgloss.Style
	Arg     lipgloss.Style
}

CodeblockStyle defines the styling for code blocks in help text.

func NewCodeblockStyle added in v1.200.0

func NewCodeblockStyle(renderer *lipgloss.Renderer) CodeblockStyle

NewCodeblockStyle creates a new code block style with Cloud Posse colors. Uses the provided renderer to ensure correct color profile. Following Fang's approach: ALL styles have the SAME background to avoid nested backgrounds.

type CustomRenderer added in v1.205.0

type CustomRenderer struct {
	// contains filtered or unexported fields
}

CustomRenderer is a markdown renderer that wraps glamour's TermRenderer with custom goldmark extensions for enhanced terminal formatting.

It supports the following custom syntax:

  • ((muted)) - Dark gray text for subtle/secondary info
  • ~~strikethrough~~ - Also renders as muted gray (GFM strikethrough restyle)
  • ==highlight== - Yellow background for emphasis
  • [!BADGE text] - Styled badges with colored backgrounds
  • > [!NOTE] - GitHub-style admonitions (NOTE, WARNING, TIP, etc.)

func NewCustomRenderer added in v1.205.0

func NewCustomRenderer(opts ...CustomRendererOption) (*CustomRenderer, error)

NewCustomRenderer creates a new CustomRenderer with the specified options. It builds a glamour renderer and extends it with custom goldmark extensions.

Custom syntax support:

  • ((text)) - Muted gray text for subtle/secondary information

The muted syntax works via AST transformation: ((text)) is parsed into a custom Muted node, then transformed to a Strikethrough node before rendering. This integrates cleanly with glamour's ANSI renderer since it already knows how to handle Strikethrough (styled as muted gray in our config).

func (*CustomRenderer) Close added in v1.205.0

func (r *CustomRenderer) Close() error

Close is a no-op for compatibility with glamour.TermRenderer interface.

func (*CustomRenderer) Render added in v1.205.0

func (r *CustomRenderer) Render(content string) (string, error)

Render converts markdown content to ANSI styled text. Stdout is temporarily suppressed during rendering to prevent glamour from printing "Warning: unhandled element" messages when it encounters markdown elements it can't handle.

type CustomRendererOption added in v1.205.0

type CustomRendererOption func(*customRendererConfig)

CustomRendererOption configures the CustomRenderer.

func WithColorProfile

func WithColorProfile(profile termenv.Profile) CustomRendererOption

WithColorProfile sets the terminal color profile.

func WithPreservedNewLines added in v1.205.0

func WithPreservedNewLines() CustomRendererOption

WithPreservedNewLines preserves newlines in the output.

func WithStyles added in v1.205.0

func WithStyles(styles *ansi.StyleConfig) CustomRendererOption

WithStyles sets the ANSI style configuration.

func WithStylesFromJSONBytes added in v1.205.0

func WithStylesFromJSONBytes(jsonBytes []byte) CustomRendererOption

WithStylesFromJSONBytes sets the ANSI style configuration from JSON bytes.

func WithWordWrap added in v1.205.0

func WithWordWrap(width int) CustomRendererOption

WithWordWrap sets the word wrap width.

type Option

type Option func(*Renderer)

Option is a function that configures the renderer.

func WithWidth

func WithWidth(width uint) Option

WithWidth sets the word wrap width for the renderer.

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer is a markdown renderer using Glamour.

func NewHelpRenderer added in v1.200.0

func NewHelpRenderer(atmosConfig *schema.AtmosConfiguration, opts ...Option) (*Renderer, error)

NewHelpRenderer creates a new Markdown renderer specifically for command help text. This uses the Cloud Posse color scheme (grayscale + purple) with transparent backgrounds.

func NewRenderer

func NewRenderer(atmosConfig schema.AtmosConfiguration, opts ...Option) (*Renderer, error)

NewRenderer creates a new Markdown renderer with the given options.

func NewTerminalMarkdownRenderer added in v1.162.0

func NewTerminalMarkdownRenderer(atmosConfig schema.AtmosConfiguration) (*Renderer, error)

func (*Renderer) Render

func (r *Renderer) Render(content string) (string, error)

Render renders markdown content to ANSI styled text.

func (*Renderer) RenderAscii added in v1.162.0

func (r *Renderer) RenderAscii(content string) (string, error)

func (*Renderer) RenderAsciiWithoutWordWrap added in v1.165.0

func (r *Renderer) RenderAsciiWithoutWordWrap(content string) (string, error)

func (*Renderer) RenderError

func (r *Renderer) RenderError(title, details, suggestion string) (string, error)

RenderError renders an error message with specific styling.

func (*Renderer) RenderErrorf added in v1.162.0

func (r *Renderer) RenderErrorf(content string, args ...interface{}) (string, error)

RenderErrorf renders an error message with specific styling.

func (*Renderer) RenderSuccess

func (r *Renderer) RenderSuccess(title, details string) (string, error)

RenderSuccess renders a success message with specific styling.

func (*Renderer) RenderWithoutWordWrap added in v1.165.0

func (r *Renderer) RenderWithoutWordWrap(content string) (string, error)

func (*Renderer) RenderWorkflow

func (r *Renderer) RenderWorkflow(content string) (string, error)

RenderWorkflow renders workflow documentation with specific styling.

Directories

Path Synopsis
Package extensions provides custom goldmark extensions for enhanced markdown syntax.
Package extensions provides custom goldmark extensions for enhanced markdown syntax.

Jump to

Keyboard shortcuts

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