Skip to content

Installation

Guido edited this page May 18, 2016 · 3 revisions

To integrate Trailer into your site, place the following code inside the head section of your HTML code:

<head>
  ...
  <script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
  <script src="http://ghoss.github.io/trailer/trailer-1.0.0.min.js"></script>
</head>

In your scripts, reference the Trailer library as follows:

<script>
  var ebnf = new EBNF();
  var example_grammar = "symbol=declaration,(const|variable);";
  ebnf.display(example_grammar, "#diagram");
</script>

where #diagram refers to a section in your HTML content to which the generated railroad diagram will be appended:

<body>
   ...
   <div id="diagram"></div>
   ...
</body>

Refer to Trailer Syntax for a specification of the grammar understood by Trailer.

Clone this wiki locally