JSPM

@choo-choo/vanilla

0.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q85575F
  • License MIT

Vanilla JS binding for choo-choo: the <choo-choo> custom element and an imperative mount() helper.

Package Exports

  • @choo-choo/vanilla
  • @choo-choo/vanilla/styles.css

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/vanilla

Plus one grammar parser of your choice if you want to pass a source:

npm install @choo-choo/parser-ebnf

Example

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