parser

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MetaExt goldmark.Extender = &metaExtension{}

MetaExt is a goldmark.Extender that parses YAML frontmatter.

Functions

func ExtractFrontmatter

func ExtractFrontmatter(source []byte) (map[string]interface{}, error)

ExtractFrontmatter extracts YAML frontmatter from markdown bytes using goldmark-meta. Returns nil, nil if no frontmatter is present.

func FrontmatterToJSON

func FrontmatterToJSON(fm map[string]interface{}) string

FrontmatterToJSON converts a frontmatter map to a JSON string. Returns "" if fm is nil.

func GetTags

func GetTags(fm map[string]interface{}) []string

GetTags extracts the "tags" field from frontmatter, handling both []interface{} and []string.

func GetTitle

func GetTitle(fm map[string]interface{}) string

GetTitle extracts the "title" field from frontmatter.

func GetWikilinks(fm map[string]interface{}) []string

GetWikilinks scans all string values in the frontmatter map for [[...]] patterns and returns the wikilink targets. Handles both string and slice values.

func MetaGet

func MetaGet(pc parser.Context) map[string]interface{}

MetaGet returns the YAML frontmatter map stored in a parser.Context.

Types

type ParseResult

type ParseResult struct {
	DocNode  store.Node
	Headings []store.Node
	Defs     []store.Node
	Tags     []store.Node // Deduplicated tag nodes
	Edges    []store.Edge
	RawLinks []RawLink
	FileInfo store.FileInfo
}

ParseResult contains all data extracted from a single markdown file.

func ParseFile

func ParseFile(absPath string, relPath string, source []byte, contentHash string) (*ParseResult, error)

ParseFile parses a markdown file and extracts nodes, edges, and raw links.

type RawLink struct {
	Text       string // Display text
	Target     string // Link target (path, wikilink name, URL)
	Kind       string // "wikilink", "markdown_link", "embed", "external"
	Line       int
	FromNodeID string // ID of the containing node
}

RawLink represents a link found during parsing, before resolution.

Jump to

Keyboard shortcuts

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