docjsonml

package
v1.0.45 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureRootWrappedBody

func EnsureRootWrappedBody(body []any) (wrapped []any, notes []string)

EnsureRootWrappedBody returns body wrapped as ["root", {}, ...body] when the input is not already root-rooted. Returns the input unchanged when:

  • body is empty
  • body[0] is the literal string "root"

notes is non-empty only when wrapping was applied.

The function does not mutate its input.

func NormalizeJsonMLBody

func NormalizeJsonMLBody(body []any) (fixed []any, notes []string)

NormalizeJsonMLBody returns a deep-cloned body with safe auto-fixes applied, plus human-readable notes describing every change.

notes is empty when no fix was needed. fixed is the parsed JSON-friendly payload ready to be marshaled.

func NormalizeJsonMLNode

func NormalizeJsonMLNode(node any) (fixed any, notes []string)

NormalizeJsonMLNode normalizes a single block node (used by `doc block insert/update --format jsonml --element <node>`).

Types

type JsonMLValidationResult

type JsonMLValidationResult struct {
	Errors   []string
	Warnings []string
}

JsonMLValidationResult holds errors and warnings from validation.

func ValidateJsonMLBodyV2

func ValidateJsonMLBodyV2(body []any) *JsonMLValidationResult

ValidateJsonMLBodyV2 validates a JSONML body using schema-v2. Only type mismatches are errors; everything else is a warning.

func ValidateJsonMLNodeV2

func ValidateJsonMLNodeV2(node any) *JsonMLValidationResult

ValidateJsonMLNodeV2 validates a single JSONML node using schema-v2.

func (*JsonMLValidationResult) HasErrors

func (r *JsonMLValidationResult) HasErrors() bool

HasErrors returns true if there are blocking errors.

func (*JsonMLValidationResult) Summary

func (r *JsonMLValidationResult) Summary() string

Summary returns a human-readable report.

type SchemaV2

type SchemaV2 struct {
	Version     string                `json:"_version"`
	Description string                `json:"_description"`
	Tags        map[string]*TagSchema `json:"tags"`
	// contains filtered or unexported fields
}

SchemaV2 is the top-level schema structure.

func (*SchemaV2) IsKnownTag

func (s *SchemaV2) IsKnownTag(tag string) bool

IsKnownTag returns true if the tag is declared in the schema.

func (*SchemaV2) TagSchemaFor

func (s *SchemaV2) TagSchemaFor(tag string) *TagSchema

TagSchemaFor returns the schema for a tag, or nil if unknown.

type TagSchema

type TagSchema struct {
	AllowedChildren []string            `json:"allowed_children"`
	Attrs           map[string]TypeSpec `json:"attrs"`
	// contains filtered or unexported fields
}

TagSchema defines the schema for a single JSONML tag.

func (*TagSchema) IsAllowedChild

func (ts *TagSchema) IsAllowedChild(childTag string) bool

IsAllowedChild returns true if childTag is in the parent's allowed_children.

type TypeSpec

type TypeSpec struct {
	Type      string              `json:"type"`                 // string|number|boolean|array|object|any|enum|union
	Min       *float64            `json:"min,omitempty"`        // for number
	Max       *float64            `json:"max,omitempty"`        // for number
	Values    []string            `json:"values,omitempty"`     // for enum
	Types     []string            `json:"types,omitempty"`      // for union: pass silently
	WarnTypes []string            `json:"warn_types,omitempty"` // for union: match → warning (not error)
	Fields    map[string]TypeSpec `json:"fields,omitempty"`     // for object (deep validation)
}

TypeSpec represents a type constraint for an attribute value. Parsed from the schema JSON's unified object format: { "type": "...", ... }

Jump to

Keyboard shortcuts

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