yaml12

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package yaml12 ports the parts of eemeli/yaml 2.9.0 that Pi's frontmatter parser runs (lexer, parser, composer, core schema, error text), so frontmatter reads and fails as it does in Pi.

Ports yaml 2.9.0 src/parse/lexer.ts. Copyright Eemeli Aro, ISC licence: permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

Positions are byte offsets into the source; LineCounter reports UTF-16 columns, as the JavaScript library does. The lexer reads a complete source, so the incremental-input states of the original are absent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(source string) (any, error)

Parse is parse(source) of the yaml package: the JavaScript value of the single document in source, or the error the library throws. A parse error message already carries the line, column and source excerpt.

func ParseOrdered

func ParseOrdered(source string) (any, error)

ParseOrdered is Parse with every object an *Object, which lists its keys in the order the library inserts them. A JavaScript object enumerates its array-index keys first, ascending, and the others in this order; the map Parse returns has no order at all.

Types

type Date

type Date struct{ MS float64 }

Date is a JavaScript Date; MS is its time value, NaN for an invalid date.

type Item

type Item struct {
	Start       []*Token
	Key         *Token
	Sep         []*Token
	Value       *Token
	ExplicitKey bool
}

Item is an entry of a block map, block sequence or flow collection.

type Map

type Map struct{ Keys, Values []any }

Map is a JavaScript Map in insertion order.

type Object

type Object struct {
	Keys   []string
	Values map[string]any
}

Object is a JavaScript object ParseOrdered built: Keys are its own string keys in insertion order (a repeated key keeps its first position), and Values holds each key's value.

type Set

type Set struct{ Values []any }

Set is a JavaScript Set in insertion order.

type Symbol

type Symbol string

Symbol is a JavaScript symbol with the given description.

type Token

type Token struct {
	Type    string
	Offset  int
	Indent  int
	Source  string
	Message string
	// Start is the props of a document.
	Start []*Token
	// StartTok is the opening bracket of a flow collection.
	StartTok *Token
	End      []*Token
	Props    []*Token
	Items    []*Item
	Value    *Token
}

Token is a CST token. Field use follows the token type exactly as in the library: End and Sep are nil where the library leaves the property undefined.

Jump to

Keyboard shortcuts

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