How to use the railroad-diagrams.MultipleChoice 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 reactbits / markdown / src / railroad.js View on Github external
export default function render(elem) {
  const $e = $(elem);
  try {
    const diagramSource = $e.text();

    // context for eval
    /* eslint-disable */
    var Diagram = railroad.Diagram;
    var ComplexDiagram = railroad.ComplexDiagram;
    var Sequence = railroad.Sequence;
    var Stack = railroad.Stack;
    var OptionalSequence = railroad.OptionalSequence;
    var Choice = railroad.Choice;
    var MultipleChoice = railroad.MultipleChoice;
    var Optional = railroad.Optional;
    var OneOrMore = railroad.OneOrMore;
    var ZeroOrMore = railroad.ZeroOrMore;
    var Terminal = railroad.Terminal;
    var NonTerminal = railroad.NonTerminal;
    var Comment = railroad.Comment;
    var Skip = railroad.Skip;
    /* eslint-enable */

    const result = eval(diagramSource).format(); // eslint-disable-line no-eval
    elem.innerHTML = ''; // eslint-disable-line
    result.addTo(elem);
    $e.find('railroad-diagram').attr('class', styles['railroad-diagram']);
  } catch (err) {
    console.log(err);
  }