parser

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSlug added in v0.8.0

func GenerateSlug(text string) string

Types

type CodeBlock

type CodeBlock struct {
	Lang   string
	Line   int
	Column int
}

CodeBlock represents a code block

func (*CodeBlock) GetLine added in v0.4.0

func (c *CodeBlock) GetLine() int

GetLine returns the line number of the code block

type Document

type Document struct {
	Path        string
	Content     []byte
	AST         ast.Node
	Root        *Section     // Root section containing the entire document tree
	FrontMatter *FrontMatter // Optional front matter at document start
}

Document represents a parsed Markdown document with hierarchical structure

func (*Document) GetSections

func (d *Document) GetSections() []*Section

GetSections returns all sections in document order

type FrontMatter

type FrontMatter struct {
	Format  string // "yaml" or "toml"
	Content string
	Data    map[string]any
	Links   []*Link
}

FrontMatter represents document front matter

type Heading

type Heading struct {
	Level  int
	Text   string
	Line   int
	Column int
	Slug   string
}

Heading represents a heading in the document

type Image

type Image struct {
	URL    string
	Alt    string
	Line   int
	Column int
}

Image represents an image in the document

func (*Image) GetLine added in v0.4.0

func (i *Image) GetLine() int

GetLine returns the line number of the image

type LineLocatable added in v0.4.0

type LineLocatable interface {
	GetLine() int
}

LineLocatable is implemented by elements that have a line position

type Link struct {
	URL        string
	Text       string
	IsInternal bool
	Line       int
	Column     int
}

Link represents a link in the document

func (*Link) GetLine added in v0.4.0

func (l *Link) GetLine() int

GetLine returns the line number of the link

type List

type List struct {
	IsOrdered bool
	Line      int
	Column    int
}

List represents a list in the document

func (*List) GetLine added in v0.4.0

func (l *List) GetLine() int

GetLine returns the line number of the list

type Parser

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

Parser handles Markdown parsing

func New

func New() *Parser

New creates a new parser instance

func (*Parser) Parse

func (p *Parser) Parse(path string, content []byte) (*Document, error)

Parse parses Markdown content

func (*Parser) ParseFile

func (p *Parser) ParseFile(path string) (*Document, error)

ParseFile parses a Markdown file

type Section

type Section struct {
	Children  []*Section // Nested subsections
	Parent    *Section   // Parent section (nil for root)
	Content   string
	StartLine int
	EndLine   int

	Heading    *Heading
	CodeBlocks []*CodeBlock
	Tables     []*Table
	Links      []*Link
	Images     []*Image
	Lists      []*List
}

Section represents a section of content under a heading

type Table

type Table struct {
	Headers []string
	Line    int
	Column  int
}

Table represents a table in the document

func (*Table) GetLine added in v0.4.0

func (t *Table) GetLine() int

GetLine returns the line number of the table

Jump to

Keyboard shortcuts

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