@choo-choo/vanilla
v0.1.3
Published
Vanilla JS binding for choo-choo: the <choo-choo> custom element and an imperative mount() helper.
Maintainers
Readme
@choo-choo/vanilla
Vanilla JS binding for Choo Choo: a <choo-choo> custom element and an imperative mount() helper for rendering a railroad diagram from a grammar source or a pre-built IR.
Install
npm install @choo-choo/vanillaPlus one grammar parser of your choice if you want to pass a source:
npm install @choo-choo/parser-ebnfExample
import { mount } from "@choo-choo/vanilla";
import { ebnfParser } from "@choo-choo/parser-ebnf";
const unmount = mount(document.querySelector("#diagram")!, {
source: `
digit = "0" | "1" ;
pair = digit , digit ;
`,
parser: ebnfParser,
rule: "pair",
});
// later, when you want to tear it down:
unmount();Prefer a declarative style? Import @choo-choo/vanilla for its side effect — it registers a <choo-choo> custom element you can drop straight into HTML.
Learn more
License
MIT
