@tabnas/ini
v0.2.0
Published
This plugin allows the [Tabnas](https://github.com/tabnas/jsonic) JSON parser to support INI syntax.
Downloads
78
Readme
@tabnas/ini
A jsonic syntax plugin that parses
INI files into JavaScript
objects — with sections, dot-nested keys, [] arrays, multiline
values, and inline comments.
Install
npm install @tabnas/ini @tabnas/parser @tabnas/jsonic @tabnas/hoover@tabnas/parser (>=2), @tabnas/jsonic (>=2), and @tabnas/hoover
(>=0) are peer dependencies.
Example
Ini is a plugin. Layer it on a Tabnas engine that already has
jsonic:
import { Tabnas } from '@tabnas/parser'
import { jsonic } from '@tabnas/jsonic'
import { Ini } from '@tabnas/ini'
const j = new Tabnas().use(jsonic).use(Ini)
j.parse('[database]\nhost = localhost\nport = 5432')
// => { database: { host: 'localhost', port: '5432' } }INI values are strings by default (port is '5432', not 5432); the
keywords true/false/null resolve to JS types. See the
how-to guide to lex numbers.
Documentation
- Tutorial — a guided first parse: pairs, sections, arrays, one option.
- How-to guide — task recipes (numbers, multiline, comments, duplicate sections, errors).
- Reference — the
Iniplugin, every option with its default, and the accepted syntax. - Concepts — how the plugin sits on the engine, the grammar model, and edge cases.
Grammar diagram
The installed grammar as a railroad/syntax diagram, generated from the
live grammar with @tabnas/railroad:
A vertical ASCII version is in doc/grammar.txt. The
grammar source is the top-level
ini-grammar.jsonic, embedded into
src/ini.ts by embed-grammar.js.
License
MIT. Copyright (c) Richard Rodger and other contributors.
