Skip to content

stury 0.2.0

Choose a tag to compare

@github-actions github-actions released this 18 Nov 11:19
· 31 commits to main since this release
Immutable release. Only release title and notes can be modified.

Library

  • New format packages toml (TOML 1.0 and 1.1), yaml (YAML 1.2, core schema), xml (XML 1.0 with namespaces and the
    internal subset), html (the WHATWG tokenizer, tree builder and serializer) and cbor (RFC 8949, with
    preferred, deterministic and length-first specs). Each has the same validate, build, find, scan, query,
    unmarshal, marshal and edit calls as json and dsv, and edits keep every byte they do not target.
  • Facts carry across formats: comments, YAML tags, anchors and styles, TOML datetimes and number forms, XML and HTML
    attributes and namespaces, CBOR tags and byte strings. A conversion writes a fact where the output holds it, and a
    comment keeps one place in every format.
  • core/model loads and dumps Odin structs under a registry of rules (tags, defaults, validators, hooks, unions,
    patch), judged with the same error kinds as a JSON Schema. core/schema compiles and binds JSON Schema drafts 4, 6,
    7, 2019-09 and 2020-12, and infers, samples, compares and converts through a schema and writes a description as
    Odin types (schema.write_odin).
  • core/diff tells the changes between two values, with keys, sets and facts. core/css matches CSS selectors
    over XML and HTML. core/regex is an Oniguruma and ECMA regex engine with Unicode 17 tables.
  • Every call that fails returns core.Error, one union that core.render writes. A refusal names the type wanted and the
    value found, and a writer's refusal names its reason in the format's words.
  • A format package takes its spec in format, as json.format(src, .Json5), and forwards comment, end_record,
    reorder and set_facts. The edit list's setter is write.set_node in every format.
  • core/records reads and writes records of every format, into documents or typed values, including CSV and TSV
    through records.Writer with Write_Options.grow_header, and reads the records under a path of keys with .Entries.
  • A repeated key follows one dups field of the read's options in every format.
  • A hex, octal or binary integer, or one with underscores, compares equal to its decimal.
  • JSON's walk passes its state in registers between states, a compact write drops blanks with vpcompressb on an
    Intel CPU with AVX512-VBMI2, and a map of 1024 keys or more is written sorted by a radix sort.
  • unmarshal of TOML, and of YAML whose members read from their tokens alone, builds no document. A TOML path read
    under stop_early parses only the statements its answer needs.
  • A TOML or XML build walks its text once. A TOML table tree keeps its comments apart, and an HTML tree grows in chunks
    that are never copied, so both builds hold less memory.
  • A typed TOML write lays out its tables in one pass and writes a bare key bare, and a typed XML write writes its
    elements with no value built in between.
  • A document read from CBOR, YAML, XML or TOML is written without examining again what its read already judged: a CBOR
    string or small integer, a YAML plain or single-quoted scalar and a TOML basic string are copied as they were read.
    A TOML basic string keeps its escapes, as a JSON string does, unless respell_strings or ascii is set.
  • An HTML write and an HTML edit check what they wrote by comparing the tree it reads back, with no second write.
  • A query over a built document stops reading an array once the element or the first key its step picks has passed.
  • records.validate reads a YAML stream or a CBOR sequence in pieces on threads, and a CBOR sequence's items are
    judged by the walk that frames them.
  • A JSON Schema whose anyOf, oneOf, not or if arms read only member names and those members' own values is
    judged with no branch run for them, and unevaluatedProperties beside such arms is settled when the schema compiles.
  • A buffer output starts at 1 KiB, and a compact write reserves no room for line breaks, so many small writes into one
    arena hold less memory.

Command line

  • Reads and writes TOML, YAML, XML, HTML, CBOR and JSON5 as well as JSON, JSONC, NDJSON, CSV and TSV. --from and --to
    take a spec after a colon (toml:1.0, html:fragment, cbor:deterministic). Without --from, the extension of the
    named files picks the format.
  • fmt converts between formats and keeps comments, number spellings, tags, directives and layout where the output has
    them. It refuses with exit 5 a value its output cannot hold and says why.
  • edit applies a jq filter to a text and keeps every byte the filter does not change, in every format. --diff tells
    the changes, per document for a YAML stream.
  • .@comment, .@comment_inline, .@comment_foot, .@style, .@tag, .@directives and .&NAME read and write
    facts and attributes, and .@(name) and .&[name] take a computed name. A step that names an unknown fact is an
    error.
  • css(selector) selects the elements of an XML or HTML input.
  • --attributes reads each attribute of an XML or HTML element as its member @NAME, and writes such a member back
    as an attribute.
  • check --schema FILE judges each input against a JSON Schema and tells every failure. check --filter F --schema S
    types a filter against the schema of its inputs. --schema-draft names the draft of a schema with no $schema.
  • diff tells what differs between two inputs, two schemas (--compat) or a schema and data.
  • schema infer, schema sample and schema gen write a JSON Schema from inputs, values that pass a schema, and the
    Odin types a model reads its values with.
  • --stream reads every format, and --seq reads JSONC and JSON5 records. --to json5 is accepted, and fmt
    reads and writes JSON5 with --check and --in-place.
  • A YAML integer past 64 bits, a TOML number with underscores and a JSON5 number with a sign or a lone point read and
    convert by their value and keep their spelling where the output has it.