parser

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package parser provides DTCG token file parsing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONParser

type JSONParser struct{}

JSONParser parses DTCG-compliant JSON token files.

func NewJSONParser

func NewJSONParser() *JSONParser

NewJSONParser creates a new JSON token parser.

func (*JSONParser) Parse

func (p *JSONParser) Parse(data []byte, opts Options) ([]*token.Token, error)

Parse parses JSON or YAML token data and returns tokens.

func (*JSONParser) ParseFile

func (p *JSONParser) ParseFile(filesystem fs.FileSystem, path string, opts Options) ([]*token.Token, error)

ParseFile parses a JSON token file and returns tokens.

type Options

type Options struct {
	// Prefix is the CSS variable prefix.
	Prefix string

	// SchemaVersion overrides auto-detection.
	SchemaVersion schema.Version

	// GroupMarkers are token names that can be both tokens and groups (draft only).
	GroupMarkers []string

	// SkipSort disables alphabetical sorting of tokens for better performance.
	// When false (default), tokens are sorted for deterministic output order.
	SkipSort bool

	// SkipPositions disables position tracking for better performance.
	// When true, Line and Character fields will be zero on all tokens.
	// Use this when LSP features (go-to-definition) aren't needed.
	SkipPositions bool
}

Options configures token parsing.

type Parser

type Parser interface {
	// Parse parses token data and returns tokens.
	Parse(data []byte, opts Options) ([]*token.Token, error)

	// ParseFile parses a token file and returns tokens.
	ParseFile(filesystem fs.FileSystem, path string, opts Options) ([]*token.Token, error)
}

Parser parses design token files.

Directories

Path Synopsis
Package common provides shared utilities for token parsing.
Package common provides shared utilities for token parsing.

Jump to

Keyboard shortcuts

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