markdown

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertKind added in v0.11.0

type AlertKind string

AlertKind is a GitHub-flavored-markdown alert type. Renderers that support alerts (GitHub and most others) color and badge them; the rest fall back to a plain blockquote, so the callout stays readable everywhere and needs no emoji.

const (
	AlertNote      AlertKind = "NOTE"      // informational
	AlertTip       AlertKind = "TIP"       // helpful suggestion
	AlertImportant AlertKind = "IMPORTANT" // action the reader must take
	AlertWarning   AlertKind = "WARNING"   // needs attention / caution
	AlertCaution   AlertKind = "CAUTION"   // risk of a negative outcome
)

type Markdown

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

Markdown represents a markdown document that can be built incrementally

func New

func New() *Markdown

New creates a new Markdown instance

func (*Markdown) AddAlert added in v0.11.0

func (m *Markdown) AddAlert(kind AlertKind, body string) *Markdown

AddAlert adds a GitHub-style alert blockquote (`> [!KIND]`) with the given body. A multi-line body keeps every line inside the blockquote, so lists (`- item`) and paragraphs render within the callout.

func (*Markdown) AddCodeBlock

func (m *Markdown) AddCodeBlock(code string, language string) *Markdown

AddCodeBlock adds a code block with optional language specification

func (*Markdown) AddHeading

func (m *Markdown) AddHeading(text string, level int) *Markdown

AddHeading adds a heading with the specified level (1-6)

func (*Markdown) AddHorizontalRule

func (m *Markdown) AddHorizontalRule() *Markdown

AddHorizontalRule adds a horizontal rule

func (*Markdown) AddList

func (m *Markdown) AddList(items []string) *Markdown

AddList adds a list of items

func (*Markdown) AddOrderedList added in v0.11.0

func (m *Markdown) AddOrderedList(items []string) *Markdown

AddOrderedList adds a numbered list of items (`1. item`), for steps whose order matters.

func (*Markdown) AddParagraph

func (m *Markdown) AddParagraph(text string) *Markdown

AddParagraph adds a paragraph of text

func (*Markdown) AddTable

func (m *Markdown) AddTable(headers []string, data [][]string, skipRepeatColumns ...int) *Markdown

AddTable adds a table with the given headers and data skipRepeatColumns is an optional slice of column indices (0-based) that should not repeat values

func (*Markdown) Print

func (m *Markdown) Print(opts ...PrintOptions) error

Print renders the markdown and outputs it according to the provided options

func (*Markdown) Render

func (m *Markdown) Render() (string, error)

Render returns the rendered markdown as a string (without printing)

func (*Markdown) String

func (m *Markdown) String() string

String returns the markdown content as a string

func (*Markdown) WriteTo

func (m *Markdown) WriteTo(w io.Writer) (int64, error)

WriteTo writes the markdown content to the provided io.Writer

func (*Markdown) WriteToTerminal

func (m *Markdown) WriteToTerminal() (int64, error)

WriteToTerminal writes the raw markdown content to stdout without glamour rendering

func (*Markdown) WriteToTerminalWithGlamour

func (m *Markdown) WriteToTerminalWithGlamour() (int64, error)

WriteToTerminalWithGlamour writes the rendered markdown content to stdout using glamour

type PrintOptions

type PrintOptions struct {
	ToTerminal bool   // Print to terminal with glamour rendering
	ToFile     string // File path to save raw markdown (empty string = don't save to file)
}

PrintOptions configures where and how to print the markdown

func DefaultPrintOptions

func DefaultPrintOptions() PrintOptions

DefaultPrintOptions returns default options (terminal only)

Jump to

Keyboard shortcuts

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