mdast

package
v0.19.768 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Code

func Code(text string) string

Code wraps text in backticks

func EscapeMDX

func EscapeMDX(s string) string

EscapeMDX escapes special characters that could be interpreted as MDX/JSX

Types

type CodeBlock

type CodeBlock struct {
	Language string
	Code     string
}

CodeBlock represents a fenced code block

func (*CodeBlock) Render

func (c *CodeBlock) Render() string

type Document

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

Document represents a complete markdown document

func NewDocument

func NewDocument() *Document

NewDocument creates a new markdown document

func (*Document) AddCodeBlock

func (d *Document) AddCodeBlock(language, code string)

AddCodeBlock adds a code block node

func (*Document) AddFrontmatter

func (d *Document) AddFrontmatter(data map[string]string)

AddFrontmatter adds YAML frontmatter to the document

func (*Document) AddHeading

func (d *Document) AddHeading(level int, text string)

AddHeading adds a heading node

func (*Document) AddListItem

func (d *Document) AddListItem(text string)

AddListItem adds a list item node

func (*Document) AddNode

func (d *Document) AddNode(node Node)

AddNode adds a node to the document

func (*Document) AddParagraph

func (d *Document) AddParagraph(text string)

AddParagraph adds a paragraph node

func (*Document) AddRaw

func (d *Document) AddRaw(text string)

AddRaw adds raw markdown text

func (*Document) AddTable

func (d *Document) AddTable(table *Table)

AddTable adds a table node

func (*Document) Render

func (d *Document) Render() string

Render renders the entire document to markdown

type Heading

type Heading struct {
	Level int
	Text  string
}

Heading represents a markdown heading

func (*Heading) Render

func (h *Heading) Render() string

type ListItem

type ListItem struct {
	Text string
}

ListItem represents a list item

func (*ListItem) Render

func (l *ListItem) Render() string

type Node

type Node interface {
	Render() string
}

Node represents a node in the markdown AST

type Paragraph

type Paragraph struct {
	Text string
}

Paragraph represents a markdown paragraph

func (*Paragraph) Render

func (p *Paragraph) Render() string

type RawText

type RawText struct {
	Text string
}

RawText represents raw markdown text

func (*RawText) Render

func (r *RawText) Render() string

type Section

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

Section represents a logical section with multiple nodes

func NewSection

func NewSection() *Section

NewSection creates a new section

func (*Section) AddCodeBlock

func (s *Section) AddCodeBlock(language, code string)

AddCodeBlock adds a code block to the section

func (*Section) AddHeading

func (s *Section) AddHeading(level int, text string)

AddHeading adds a heading to the section

func (*Section) AddListItem

func (s *Section) AddListItem(text string)

AddListItem adds a list item to the section

func (*Section) AddParagraph

func (s *Section) AddParagraph(text string)

AddParagraph adds a paragraph to the section

func (*Section) Render

func (s *Section) Render() string

type Table

type Table struct {
	Headers []string
	Rows    [][]string
}

Table represents a markdown table

func NewTable

func NewTable(headers []string) *Table

NewTable creates a new table with headers

func (*Table) AddRow

func (t *Table) AddRow(cells []string)

AddRow adds a row to the table

func (*Table) Render

func (t *Table) Render() string

Jump to

Keyboard shortcuts

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