How to use the railroad-diagrams.ComplexDiagram function in railroad-diagrams

To help you get started, we’ve selected a few railroad-diagrams examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github matthijsgroen / ebnf2railroad / src / report-builder.js View on Github external
const productionToDiagram = (production, options) => {
  if (production.identifier) {
    return production.complex
      ? ComplexDiagram(productionToDiagram(production.definition, options))
      : Diagram(productionToDiagram(production.definition, options));
  }
  if (production.terminal) {
    return Terminal(production.terminal);
  }
  if (production.nonTerminal) {
    return NonTerminal(production.nonTerminal, {
      href: `#${dasherize(production.nonTerminal)}`
    });
  }
  if (production.skip) {
    return Skip();
  }
  if (production.specialSequence) {
    const sequence = NonTerminal(" " + production.specialSequence + " ", {});
    sequence.attrs.class = "special-sequence";