selector

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SectionNodes

func SectionNodes(heading *ast.Heading) []ast.Node

SectionNodes returns the heading and all subsequent sibling nodes that belong to its section (up to but not including the next heading of the same or higher level).

Types

type Selector

type Selector interface {
	Matches(node ast.Node, source []byte) bool
	String() string
}

Selector represents a CSS-like selector for Markdown AST nodes.

type SelectorList

type SelectorList []Selector

SelectorList is a comma-separated list of selectors.

func Parse

func Parse(input string) (SelectorList, error)

Parse parses a CSS-like selector string into a SelectorList.

func (SelectorList) FindAll

func (sl SelectorList) FindAll(root ast.Node, source []byte) []ast.Node

FindAll returns all nodes in root (walking the full tree) that match the selector list. For heading matches, the full section is expanded.

func (SelectorList) MatchTopLevel

func (sl SelectorList) MatchTopLevel(root ast.Node, source []byte) []ast.Node

MatchTopLevel returns all direct children of root that match the selector list. For heading matches, the full section is expanded (heading + subsequent siblings until a heading of the same or higher level).

Jump to

Keyboard shortcuts

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