parser

package
v0.35.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	Frontmatter      string
	FrontmatterRange Range
	Template         string
	TemplateRange    Range
	Scripts          []Script
	Styles           []Style
	Imports          []Import
	Tokens           []Token
	Expressions      []Expression
	Directives       []Directive
}

func Parse

func Parse(content string) (*Component, error)

func (*Component) String

func (c *Component) String() string

type Directive

type Directive struct {
	Name      string
	Condition string
	Range     Range
}

type Expression

type Expression struct {
	Content   string
	Range     Range
	Variables []string
}

type Import

type Import struct {
	Path        string
	Alias       string
	IsDefault   bool
	IsComponent bool
}

type MDXDocument

type MDXDocument struct {
	Frontmatter map[string]interface{}
	Content     string
	HTML        string
	Layout      string
	Components  []string
	Imports     []Import
}

func ParseMDX

func ParseMDX(content string) (*MDXDocument, error)

func (*MDXDocument) GetFrontmatterBool

func (d *MDXDocument) GetFrontmatterBool(key string) bool

func (*MDXDocument) GetFrontmatterInt

func (d *MDXDocument) GetFrontmatterInt(key string) int

func (*MDXDocument) GetFrontmatterString

func (d *MDXDocument) GetFrontmatterString(key string) string

func (*MDXDocument) HasComponent

func (d *MDXDocument) HasComponent(name string) bool

type MarkdownDocument

type MarkdownDocument struct {
	Frontmatter map[string]interface{}
	Content     string
	HTML        string
	Layout      string
}

func ParseMarkdown

func ParseMarkdown(content string) (*MarkdownDocument, error)

func ParseMarkdownWithYAMLFrontmatter

func ParseMarkdownWithYAMLFrontmatter(content string) (*MarkdownDocument, error)

func (*MarkdownDocument) GetFrontmatterBool

func (d *MarkdownDocument) GetFrontmatterBool(key string) bool

func (*MarkdownDocument) GetFrontmatterInt

func (d *MarkdownDocument) GetFrontmatterInt(key string) int

func (*MarkdownDocument) GetFrontmatterString

func (d *MarkdownDocument) GetFrontmatterString(key string) string

type Position

type Position struct {
	Line   int
	Column int
}

type Range

type Range struct {
	Start Position
	End   Position
}

func NewRange

func NewRange(startLine, startCol, endLine, endCol int) Range

type Script

type Script struct {
	Content  string
	IsModule bool
	Language string
}

type Style

type Style struct {
	Content string
	Scoped  bool
}

type Token

type Token struct {
	Type  TokenType
	Value string
	Range Range
}

type TokenType

type TokenType int
const (
	TokenFrontmatter TokenType = iota
	TokenTemplate
	TokenScript
	TokenStyle
	TokenDirective
	TokenExpression
	TokenHTMLTag
	TokenComment
)

func (TokenType) String

func (t TokenType) String() string

Jump to

Keyboard shortcuts

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