@tabnas/yaml
v0.2.0
Published
This plugin allows the [Tabnas](https://github.com/tabnas/jsonic) JSON parser to support a core subset of YAML syntax.
Downloads
75
Readme
@tabnas/yaml
A Tabnas grammar plugin that parses
a core subset of YAML into plain JavaScript values, built on the
relaxed-JSON jsonic grammar.
Install
npm install @tabnas/yaml @tabnas/jsonic @tabnas/parser@tabnas/jsonic (>= 2) and @tabnas/parser (>= 2) are peer
dependencies.
Example
Register the plugin on a Tabnas engine that already has the jsonic
grammar, then parse:
const { Tabnas } = require('@tabnas/parser')
const { jsonic } = require('@tabnas/jsonic')
const { Yaml } = require('@tabnas/yaml')
const j = new Tabnas().use(jsonic).use(Yaml)
j.parse("name: Alice\nitems:\n - one\n - two\n") // => { name: 'Alice', items: ['one', 'two'] }Documentation
The docs follow the Diátaxis four-quadrant structure:
- Tutorial — parse your first document, step by step.
- How-to guide — focused task recipes (flow collections,
block scalars, anchors, multi-document streams, the
metaoption). - Reference — the public API, every option, and the full list of accepted syntax.
- Concepts — how the plugin extends the engine, and why.
The Go port lives in ../go with its own
docs.
Grammar diagram
The installed grammar as a railroad/syntax diagram, generated from the
live grammar with @tabnas/railroad:
ASCII version: doc/grammar.txt.
License
MIT. Copyright (c) Richard Rodger.
