diff --git a/dist/www/fonts/slate.eot b/dist/www/fonts/slate.eot new file mode 100755 index 000000000..13c4839a1 Binary files /dev/null and b/dist/www/fonts/slate.eot differ diff --git a/dist/www/fonts/slate.svg b/dist/www/fonts/slate.svg new file mode 100644 index 000000000..5f3498230 --- /dev/null +++ b/dist/www/fonts/slate.svg @@ -0,0 +1,14 @@ + + + +Generated by IcoMoon + + + + + + + + + + diff --git a/dist/www/fonts/slate.ttf b/dist/www/fonts/slate.ttf new file mode 100755 index 000000000..ace9a46a7 Binary files /dev/null and b/dist/www/fonts/slate.ttf differ diff --git a/dist/www/fonts/slate.woff b/dist/www/fonts/slate.woff new file mode 100755 index 000000000..1e72e0ee0 Binary files /dev/null and b/dist/www/fonts/slate.woff differ diff --git a/dist/www/fonts/slate.woff2 b/dist/www/fonts/slate.woff2 new file mode 100755 index 000000000..7c585a727 Binary files /dev/null and b/dist/www/fonts/slate.woff2 differ diff --git a/dist/www/images/header.png b/dist/www/images/header.png new file mode 100644 index 000000000..06159b2c9 Binary files /dev/null and b/dist/www/images/header.png differ diff --git a/dist/www/images/logo.png b/dist/www/images/logo.png new file mode 100644 index 000000000..8cd6063a5 Binary files /dev/null and b/dist/www/images/logo.png differ diff --git a/dist/www/images/logo.psd b/dist/www/images/logo.psd new file mode 100644 index 000000000..5de9ecaa2 Binary files /dev/null and b/dist/www/images/logo.psd differ diff --git a/dist/www/images/navbar.png b/dist/www/images/navbar.png new file mode 100644 index 000000000..df38e90d8 Binary files /dev/null and b/dist/www/images/navbar.png differ diff --git a/dist/www/index.html b/dist/www/index.html new file mode 100644 index 000000000..c0dbefa21 --- /dev/null +++ b/dist/www/index.html @@ -0,0 +1,1260 @@ + + + + + + + mermaid - Generation of diagrams and flowcharts from text in a similar manner as markdown. + + + + + + + + + + + + + + + + + NAV + + + + +
+ + + + + +
+
+ +
+
+
+
+

mermaid

+

Alt text

+
+

Generation of diagrams and flowcharts from text in a similar manner as markdown.

+
+

Ever wanted to simplify documentation and avoid heavy tools like Visio when explaining your code?

+

This is why mermaid was born, a simple markdown-like script language for generating charts from text via javascript. Try it using our editor.

+

Code examples below:

+

An example of a flowchart

+
graph TD;
+    A-->B;
+    A-->C;
+    B-->D;
+    C-->D;

An example of a sequence diagram

+
sequenceDiagram
+    participant Alice
+    participant Bob
+    Alice->John: Hello John, how are you?
+    loop Healthcheck
+        John->John: Fight against hypochondria
+    end
+    Note right of John: Rational thoughts <br/>prevail...
+    John-->Alice: Great!
+    John->Bob: How about you?
+    Bob-->John: Jolly good!

Example code for a gantt diagram

+
gantt
+        dateFormat  YYYY-MM-DD
+        title Adding GANTT diagram functionality to mermaid
+        section A section
+        Completed task            :done,    des1, 2014-01-06,2014-01-08
+        Active task               :active,  des2, 2014-01-09, 3d
+        Future task               :         des3, after des2, 5d
+        Future task2               :         des4, after des3, 5d
+        section Critical tasks
+        Completed task in the critical line :crit, done, 2014-01-06,24h
+        Implement parser and jison          :crit, done, after des1, 2d
+        Create tests for parser             :crit, active, 3d
+        Future task in critical line        :crit, 5d
+        Create tests for renderer           :2d
+        Add to mermaid                      :1d

Play with mermaid using this editor or this live editor.

+

Further reading

+ +

Credits

+

Many thanks to the d3 and dagre-d3 projects for providing
the graphical layout and drawing libraries! Thanks also to the
js-sequence-diagram project for usage of the grammar for the
sequence diagrams.

+

Mermaid was created by Knut Sveidqvist for easier documentation.

+

Knut has not done all work by himself, here is the full list of the projects contributors.

+ +

Usage

+

Installation

+

Either use the npm or bower package managers as per below:

+
bower install mermaid --save-dev
npm install mermaid --save-dev

Or download javascript files as per the url below, note that #version# should be replaced with version of choice:

+
https://cdn.rawgit.com/knsv/mermaid/#version#/dist/mermaid.min.js

Ex:

+ +

There are some bundles to choose from:

+ +

Important:

+
+

It's best to use a specific tag or commit hash in the URL (not a branch). Files are cached permanently after the first request.

+
+

Read more about that at https://rawgit.com/

+

Simple usage on a web page

+

The easiest way to integrate mermaid on a web page requires two elements:

+
    +
  1. Inclusion of the mermaid framework in the html page using a script tag
  2. +
  3. A graph definition on the web page
  4. +
+

If these things are in place mermaid listens to the page load event and when fires, when the page has loaded, it will
locate the graphs n the page and transform them to svg files.

+

Include mermaid on your web page:

+
<script src="mermaid.min.js"></script>
+<script>mermaid.initialize({startOnLoad:true});</script>

Further down on your page mermaid will look for tags with class="mermaid". From these tags mermaid will try to
read the chart definiton which will be replaced with the svg chart.

+

Define a chart like this:

+
<div class="mermaid">
+    CHART DEFINITION GOES HERE
+</div>

Would end up like this:

+
<div class="mermaid" id="mermaidChart0">
+    <svg>
+        Chart ends up here
+    </svg>
+</div>

An id is also added to mermaid tags without id.

+

Calling mermaid.init

+

By default, mermaid.init will be called when the document is ready, finding all elements with
class="mermaid". If you are adding content after mermaid is loaded, or otherwise need
finer-grained control of this behavior, you can call init yourself with:

+ +

Example:

+
mermaid.init({noteMargin: 10}, ".someOtherClass");

Or with no config object, and a jQuery selection:

+
mermaid.init(undefined, $("#someId .yetAnotherClass"));
+ +

Usage with browserify

+

The reader is assumed to know about CommonJS style of module handling and how to use browserify. If not a good place
to start would be http://browserify.org/ website.

+

Minimalistic javascript:

+
mermaid = require('mermaid');
+console.log('Test page! mermaid version'+mermaid.version());

Bundle the javascript with browserify.

+

Us the created bundle on a web page as per example below:

+
<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="UTF-8">
+    <link rel="stylesheet" href="mermaid.css" />
+    <script src="bundle.js"></script>
+</head>
+<body>
+    <div class="mermaid">
+        graph LR
+            A-->B
+            B-->C
+            C-->A
+            D-->C
+    </div>
+</body>
+</html>

API usage

+

The main idea with the API is to be able to call a render function with graph defintion as a string. The render function
will render the graph and call a callback with the resulting svg code. With this approach it is up to the site creator to
fetch the graph definition from the site, perhaps from a textarea, render it and place the graph somewhere in the site.

+

To do this, include mermaidAPI on your web website instead of mermaid.js. The example below show an outline of how this
could be used. The example just logs the resulting svg to the javascript console.

+
<script src="mermaidAPI.js"></script>
+
+<script>
+    mermaidAPI.initialize({
+        startOnLoad:false
+        });
+        // Example of using the API
+    $(function(){
+        var graphDefinition = 'graph TB\na-->b';
+        var graph = mermaidAPI.render(graphDefinition);
+        $("#graphDiv").html(graph);
+    });
+</script>

Sample of API usage together with browserify

+
$ = require('jquery');
+mermaidAPI = require('mermaid').mermaidAPI;
+mermaidAPI.initialize({
+    startOnLoad:false
+    });
+
+$(function(){
+    var graphDefinition = 'graph TB\na-->b';
+    var cb = function(html){
+        console.log(html);
+    }
+    mermaidAPI.render('id1',graphDefinition,cb);
+});

Example of a marked renderer

+

This is the renderer used for transforming the documentation from markdown to html with mermaid diagrams in the html.

+
    var renderer = new marked.Renderer();
+    renderer.code = function (code, language) {
+        if(code.match(/^sequenceDiagram/)||code.match(/^graph/)){
+            return '<div class="mermaid">'+code+'</div>';
+        }
+        else{
+            return '<pre><code>'+code+'</code></pre>';
+        }
+    };

Another example in coffeescript that also includes the mermaid script tag into the generated markup.

+
marked = require 'marked'
+
+module.exports = (options) ->
+  hasMermaid = false
+  renderer = new marked.Renderer()
+  renderer.defaultCode = renderer.code
+  renderer.code = (code, language) ->
+    if language is 'mermaid'
+      html = ''
+      if not hasMermaid
+        hasMermaid = true
+        html += '&ltscript src="'+options.mermaidPath+'"></script>'
+      html + '&ltdiv class="mermaid">'+code+'</div>'
+    else
+      @defaultCode(code, language)
+
+  renderer

Advanced usage

+

Error handling

+

When the parser encounters invalid syntax the mermaid.parseError function is called. It is possible to override this
function in order to handle the error in an application specific way.

+

Parsing text without rendering

+

It is also possible to validate the syntax before rendering in order to streamline the user experience. The function
mermaid.parse(txt) takes a text string as an argument and returns true if the text is syntactically correct and
false if it is not. The parseError function will be called when the parse function returns false.

+

The code-example below in meta code illustrates how this could work:

+

+mermaid.parseError = function(err,hash){
+    displayErrorInGui(err);
+};
+
+var textFieldUpdated = function(){
+    var textStr = getTextFromFormField('code');
+
+    if(mermaid.parse(textStr)){
+        reRender(textStr)
+    }
+};
+
+bindEventHandler('change', 'code', textFieldUpdated);

Configuration

+

Mermaid takes a number of options which lets you tweak the rendering of the diagrams. Currently there are three ways of
setting the options in mermaid.

+
    +
  1. Instantiation of the configuration using the initialize call
  2. +
  3. Using the global mermaid object - deprecated
  4. +
  5. using the global mermaid_config object - deprecated
  6. +
  7. Instantiation of the configuration using the mermaid.init call
  8. +
+

The list above has two ways to many of doing this. Three are deprecated and will eventually be removed. The list of
configuration objects are described in the mermaidAPI documentation.

+

Using the mermaidAPI.initialize/mermaid.initialize call

+

The future proof way of setting the configuration is by using the initialization call to mermaid or mermaidAPi depending
on what kind of integration you use.

+
    <script src="../dist/mermaid.js"></script>
+    <script>
+        var config = {
+            startOnLoad:true,
+            flowchart:{
+                    useMaxWidth:false,
+                    htmlLabels:true
+            }
+        };
+        mermaid.initialize(config);
+    </script>
+ + +

Using the mermaid object

+

Is it possible to set some configuration via the mermaid object. The two parameters that are supported using this
approach are:

+ +
mermaid.startOnLoad = true;
+ +

Using the mermaid_config

+

Is it possible to set some configuration via the mermaid object. The two parameters that are supported using this
approach are:

+ +
mermaid_config.startOnLoad = true;
+ +

Using the mermaid.init call

+

Is it possible to set some configuration via the mermaid object. The two parameters that are supported using this
approach are:

+ +
mermaid_config.startOnLoad = true;
+ +

Flowcharts - Basic Syntax

+

Graph

+

This statement declares a new graph and the direction of the graph layout.

+
%% Example code
+graph TD

This declares a graph oriented from top to bottom.

+
graph TD + Start --> Stop
%% Example code
+graph LR

This declares a graph oriented from left to right.

+

Possible directions are:

+ +
graph LR + Start --> Stop

Nodes & shapes

+

A node (default)

+
graph LR
+    id1
graph LR + id

Note that the id is what is displayed in the box.

+

A node with text

+

It is also possible to set text in the box that differs from the id. If this is done several times, it is the last text
found for the node that will be used. Also if you define edges for the node later on, you can omit text definitions. The
one previously defined will be used when rendering the box.

+
graph LR
+    id1[This is the text in the box]
graph LR + id1[This is the text in the box]

A node with round edges

+
graph LR
+    id1(This is the text in the box);
graph LR + id1(This is the text in the box)

A node in the form of a circle

+
graph LR
+    id1((This is the text in the circle));
graph LR + id1((This is the text in the circle))

A node in an asymetric shape

+
graph LR
+    id1>This is the text in the box]
graph LR + id1>This is the text in the box]

Currently only the shape above is possible and not its mirror. This might change with future releases.

+

A node (rhombus)

+
graph LR
+    id1{This is the text in the box}
graph LR + id1{This is the text in the box}
+

Nodes can be connected with links/edges. It is possible to have different types of links or attach a text string to a link.

+ +
graph LR
+    A-->B
graph LR;
+    A-->B
+
graph LR
+    A --- B
graph LR; + A --- B
+
A-- This is the text --- B

or

+
A---|This is the text|B;
graph LR; + A-- This is the text ---B
+

-.->

+
graph LR; + A-.->B;
+

-. text .->

+
graph LR; + A-. text .-> B
+

==>

+
graph LR; + A ==> B
+

== text ==>

+
graph LR; + A == text ==> B

Subgraphs

+
subgraph title
+    graph definition
+end

An example below:

+
 %% Subgraph example
+ graph TB
+         subgraph one
+         a1-->a2
+         end
+         subgraph two
+         b1-->b2
+         end
+         subgraph three
+         c1-->c2
+         end
+         c1-->a2
graph TB + c1-->a2 + subgraph one + a1-->a2 + end + subgraph two + b1-->b2 + end + subgraph three + c1-->c2 + end

Interaction

+

It is possible to bind a click event to a node:

+
click nodeId callback
+

Styling and classes

+ +

It is possible to style links. For instance you might want to style a link that is going backwards in the flow. As links
have no ids in the same way as nodes, some other way of deciding what style the links should be attached to is required.
Instead of ids, the order number of when the link was defined in the graph is used. In the example below the style
defined in the linkStyle statement will belong to the fourth link in the graph:

+
linkStyle 3 stroke:#ff3,stroke-width:4px;

Styling a node

+

It is possible to apply specific styles such as a thicker border or a different background color to a node.

+
%% Example code
+graph LR
+    id1(Start)-->id2(Stop)
+    style id1 fill:#f9f,stroke:#333,stroke-width:4px;
+    style id2 fill:#ccf,stroke:#f66,stroke-width:2px,stroke-dasharray: 5, 5;
graph LR + id1(Start)-->id2(Stop) + style id1 fill:#f9f,stroke:#333,stroke-width:4px + style id2 fill:#ccf,stroke:#f66,stroke-width:2px,stroke-dasharray: 5, 5

Classes

+

More convenient then defining the style everytime is to define a class of styles and attach this class to the nodes that
should have a different look.

+

a class definition looks like the example below:

+
    classDef className fill:#f9f,stroke:#333,stroke-width:4px;

Attachment of a class to a node is done as per below:

+
    class nodeId1 className;

It is also possible to attach a class to a list of nodes in one statement:

+
    class nodeId1,nodeId2 className;

Default class

+

If a class is named default it will be assigned to all classes without specific class definitions.

+
    classDef default fill:#f9f,stroke:#333,stroke-width:4px;
+ +

Below is the new declaration of the graph edges which is also valid along with the old declaration of the graph edges.

+
    A[Hard edge] -->|Link text| B(Round edge)
+    B --> C{Decision}
+    C -->|One| D[Result one]
+    C -->|Two| E[Result two]
graph LR + A[Hard edge] -->|Link text| B(Round edge) + B --> C{Decision} + C -->|One| D[Result one] + C -->|Two| E[Result two]
+

Sequence diagrams

+
+

A Sequence diagram is an interaction diagram that shows how processes operate with one another and in what order.

+
+

Mermaid can render sequence diagrams. The code snippet below:

+
%% Example of sequence diagram
+sequenceDiagram
+    Alice->>John: Hello John, how are you?
+    John-->>Alice: Great!

Renders the following diagram:

+
sequenceDiagram + Alice->>John: Hello John, how are you? + John-->>Alice: Great!

Syntax

+

Participants

+

The participants can be defined implicitly as in the first example on this page. The participants or actors are
rendered in order of appearance in the diagram source text. Sometimes you might want to show the participants in a
different order than how they appear in the first message. It is possible to specify the actor's order of
appearance by doing the following:

+
%% Example of sequence diagram
+sequenceDiagram
+    participant John
+    participant Alice
+    Alice->>John: Hello John, how are you?
+    John-->>Alice: Great!

Renders to the diagram below:

+
sequenceDiagram + participant John + participant Alice + Alice->>John: Hello John, how are you? + John-->>Alice: Great!

Messages

+

Messages can be of two displayed either solid or with a dotted line.

+
[Actor][Arrow][Actor]:Message text

There are six types of arrows currently supported:

+

-> which will render a solid line without arrow

+

--> which will render a dotted line without arrow

+

->> which will render a solid line with arrowhead

+

-->> which will render a dotted line with arrowhead

+

-x which will render a solid line with a cross at the end (async)

+

--x which will render a dotted line with a cross at the end (async)

+

Notes

+

It is possible to add notes to a sequence diagram. This is done by the notation
Note [ right | left ] of [Actor]: Text in note content

+

See the example below:

+
%% Example of sequence diagram
+sequenceDiagram
+    participant John
+    Note right of John: Text in note

Renders to the diagram below:

+
sequenceDiagram + participant John + Note right of John: Text in note

It is possible to break text into different rows by using <br/> as a line breaker.

+
%% Example of sequence diagram
+sequenceDiagram
+    participant John
+    Note left of John: Text in note spanning several rows.
sequenceDiagram + participant John + Note left of John: Text in note spanning several rows.

Loops

+

It is possible to express loops in a sequence diagram. This is done by the notation

+
loop Loop text
+... statements ...
+end

See the example below

+
%% Example of sequence diagram
+sequenceDiagram
+    Alice->John: Hello John, how are you?
+    loop Reply every minute
+        John-->Alice: Great!
+    end
sequenceDiagram + Alice->John: Hello John, how are you? + loop Every minute + John-->Alice: Great! + end

Alt

+

It is possible to express alternative paths in a sequence diagram. This is done by the notation

+
alt Describing text
+... statements ...
+else
+... statements ...
+end

or if there is sequence that is optionat (if without else).

+
opt Describing text
+... statements ...
+end

See the example below

+
%% Example of sequence diagram
+    sequenceDiagram
+        Alice->>Bob: Hello Bob, how are you?
+        alt is sick
+            Bob->>Alice: Not so good :(
+        else is well
+            Bob->>Alice: Feeling fresh like a daisy
+        end
+        opt Extra response
+            Bob->>Alice: Thanks for asking
+        end
sequenceDiagram + Alice->>Bob: Hello Bob, how are you? + alt is sick + Bob->>Alice: Not so good :( + else is well + Bob->>Alice: Feeling fresh like a daisy + end + opt Extra response + Bob->>Alice: Thanks for asking + end

Styling

+

Styling of the a sequence diagram is done by defining a number of css classes. During rendering these classes are extracted from the

+

Classes used

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ClassDescription
actorStyle for the actor box at the top of the diagram.
text.actorStyles for text in the actor box at the top of the diagram.
actor-lineThe vertical line for an actor.
messageLine0Styles for the solid message line.
messageLine1Styles for the dotted message line.
messageTextDefines styles for the text on the message arrows.
labelBoxDefines styles label to left in a loop.
labelTextStyles for the text in label for loops.
loopTextStyles for the text in the loop box.
loopLineDefines styles for the lines in the loop box.
noteStyles for the note box.
noteTextStyles for the text on in the note boxes.
+

Sample stylesheet

+

+body {
+    background: white;
+}
+
+.actor {
+    stroke: #CCCCFF;
+    fill: #ECECFF;
+}
+text.actor {
+    fill:black;
+    stroke:none;
+    font-family: Helvetica;
+}
+
+.actor-line {
+    stroke:grey;
+}
+
+.messageLine0 {
+    stroke-width:1.5;
+    stroke-dasharray: "2 2";
+    marker-end:"url(#arrowhead)";
+    stroke:black;
+}
+
+.messageLine1 {
+    stroke-width:1.5;
+    stroke-dasharray: "2 2";
+    stroke:black;
+}
+
+#arrowhead {
+    fill:black;
+
+}
+
+.messageText {
+    fill:black;
+    stroke:none;
+    font-family: 'trebuchet ms', verdana, arial;
+    font-size:14px;
+}
+
+.labelBox {
+    stroke: #CCCCFF;
+    fill: #ECECFF;
+}
+
+.labelText {
+    fill:black;
+    stroke:none;
+    font-family: 'trebuchet ms', verdana, arial;
+}
+
+.loopText {
+    fill:black;
+    stroke:none;
+    font-family: 'trebuchet ms', verdana, arial;
+}
+
+.loopLine {
+    stroke-width:2;
+    stroke-dasharray: "2 2";
+    marker-end:"url(#arrowhead)";
+    stroke: #CCCCFF;
+}
+
+.note {
+    stroke: #decc93;
+    stroke: #CCCCFF;
+    fill: #fff5ad;
+}
+
+.noteText {
+    fill:black;
+    stroke:none;
+    font-family: 'trebuchet ms', verdana, arial;
+    font-size:14px;
+}

Configuration

+

Is it possible to adjust the margins for rendering the sequence diagram.

+

This is done by defining mermaid.sequenceConfig or by the CLI to use a json file with the configuration. How to use
the CLI is described in the mermaidCLI page.
mermaid.sequenceConfig can be set to a JSON string with config parameters or the corresponding object.

+
mermaid.sequenceConfig = {
+    diagramMarginX:50,
+    diagramMarginY:10,
+    boxTextMargin:5,
+    noteMargin:10,
+    messageMargin:35,
+    mirrorActors:true
+    };

Possible configration params:

+ + + + + + + + + + + + + + + + + + + + +
ParamDescriotionDefault value
mirrorActorTurns on/off the rendering of actors below the diagram as well as above itfalse
bottomMarginAdjAdjusts how far down the graph ended. Wide borders styles with css could generate unwantewd clipping which is why this config param exists.1
+ +

Gant diagrams

+
+

A Gantt chart is a type of bar chart, first developed by Karol Adamiecki in 1896, and independently by Henry Gantt in the 1910s, that illustrates a project schedule. Gantt charts illustrate the start and finish dates of the terminal elements and summary elements of a project.

+
+

Mermaid can render Gantt diagrams. The code snippet below:

+
%% Example of sequence diagram
+gantt
+    title A Gantt Diagram
+
+    section Section
+    A task           :a1, 2014-01-01, 30d
+    Another task     :after a1  , 20d
+    section Another
+    Task in sec      :2014-01-12  , 12d
+    anther task      : 24d

Renders the following diagram:

+
gantt + title A Gantt Diagram + dateFormat YYYY-MM-DD + section Section + A task :a1, 2014-01-01, 30d + Another task :after a1 , 20d + section Another + Task in sec :2014-01-12 , 12d + anther task : 24d

Syntax

+
%% Example with slection of syntaxes
+        gantt
+        dateFormat  YYYY-MM-DD
+        title Adding GANTT diagram functionality to mermaid
+
+        section A section
+        Completed task            :done,    des1, 2014-01-06,2014-01-08
+        Active task               :active,  des2, 2014-01-09, 3d
+        Future task               :         des3, after des2, 5d
+        Future task2               :         des4, after des3, 5d
+
+        section Critical tasks
+        Completed task in the critical line :crit, done, 2014-01-06,24h
+        Implement parser and jison          :crit, done, after des1, 2d
+        Create tests for parser             :crit, active, 3d
+        Future task in critical line        :crit, 5d
+        Create tests for renderer           :2d
+        Add to mermaid                      :1d
+
+        section Documentation
+        Describe gantt syntax               :active, a1, after des1, 3d
+        Add gantt diagram to demo page      :after a1  , 20h
+        Add another diagram to demo page    :doc1, after a1  , 48h
+
+        section Last section
+        Describe gantt syntax               :after doc1, 3d
+        Add gantt diagram to demo page      : 20h
+        Add another diagram to demo page    : 48h

Renders like below:

+
gantt + dateFormat YYYY-MM-DD + title Adding GANTT diagram functionality to mermaid + + section A section + Completed task :done, des1, 2014-01-06,2014-01-08 + Active task :active, des2, 2014-01-09, 3d + Future task : des3, after des2, 5d + Future task2 : des4, after des3, 5d + + section Critical tasks + Completed task in the critical line :crit, done, 2014-01-06,24h + Implement parser and jison :crit, done, after des1, 2d + Create tests for parser :crit, active, 3d + Future task in critical line :crit, 5d + Create tests for renderer :2d + Add to mermaid :1d + + section Documentation + Describe gantt syntax :active, a1, after des1, 3d + Add gantt diagram to demo page :after a1 , 20h + Add another diagram to demo page :doc1, after a1 , 48h + + section Last section + Describe gantt syntax :after doc1, 3d + Add gantt diagram to demo page : 20h + Add another diagram to demo page : 48h

title

+

Tbd

+

Sections statements

+

Tbd

+

Setting dates

+

Tbd

+

Date format

+

Tbd

+

Diagram definition

+

Input Example Description:

+
YYYY    2014    4 digit year
+YY    14    2 digit year
+Q    1..4    Quarter of year. Sets month to first month in quarter.
+M MM    1..12    Month number
+MMM MMMM    January..Dec    Month name in locale set by moment.locale()
+D DD    1..31    Day of month
+Do    1st..31st    Day of month with ordinal
+DDD DDDD    1..365    Day of year
+X    1410715640.579    Unix timestamp
+x    1410715640579    Unix ms timestamp
+
+Input    Example    Description
+H HH    0..23    24 hour time
+h hh    1..12    12 hour time used with a A.
+a A    am pm    Post or ante meridiem
+m mm    0..59    Minutes
+s ss    0..59    Seconds
+S    0..9    Tenths of a second
+SS    0..99    Hundreds of a second
+SSS    0..999    Thousandths of a second
+Z ZZ    +12:00    Offset from UTC as +-HH:mm, +-HHmm, or Z

More info in: http://momentjs.com/docs/#/parsing/string-format/

+

Scale

+
%a - abbreviated weekday name.
+%A - full weekday name.
+%b - abbreviated month name.
+%B - full month name.
+%c - date and time, as "%a %b %e %H:%M:%S %Y".
+%d - zero-padded day of the month as a decimal number [01,31].
+%e - space-padded day of the month as a decimal number [ 1,31]; equivalent to %_d.
+%H - hour (24-hour clock) as a decimal number [00,23].
+%I - hour (12-hour clock) as a decimal number [01,12].
+%j - day of the year as a decimal number [001,366].
+%m - month as a decimal number [01,12].
+%M - minute as a decimal number [00,59].
+%L - milliseconds as a decimal number [000, 999].
+%p - either AM or PM.
+%S - second as a decimal number [00,61].
+%U - week number of the year (Sunday as the first day of the week) as a decimal number [00,53].
+%w - weekday as a decimal number [0(Sunday),6].
+%W - week number of the year (Monday as the first day of the week) as a decimal number [00,53].
+%x - date, as "%m/%d/%Y".
+%X - time, as "%H:%M:%S".
+%y - year without century as a decimal number [00,99].
+%Y - year with century as a decimal number.
+%Z - time zone offset, such as "-0700".
+%% - a literal "%" character.

More info in: https://github.com/mbostock/d3/wiki/Time-Formatting

+

Styling

+

Styling of the a sequence diagram is done by defining a number of css classes. During rendering these classes are extracted from the

+

Classes used

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ClassDescription
actorStyle for the actor box at the top of the diagram.
text.actorStyles for text in the actor box at the top of the diagram.
actor-lineThe vertical line for an actor.
messageLine0Styles for the solid message line.
messageLine1Styles for the dotted message line.
messageTextDefines styles for the text on the message arrows.
labelBoxDefines styles label to left in a loop.
labelTextStyles for the text in label for loops.
loopTextStyles for the text in the loop box.
loopLineDefines styles for the lines in the loop box.
noteStyles for the note box.
noteTextStyles for the text on in the note boxes.
+

Sample stylesheet

+

+            .grid .tick {
+                stroke: lightgrey;
+                opacity: 0.3;
+                shape-rendering: crispEdges;
+            }
+            .grid path {
+                stroke-width: 0;
+            }
+
+
+            #tag {
+                color: white;
+                background: #FA283D;
+                width: 150px;
+                position: absolute;
+                display: none;
+                padding:3px 6px;
+                margin-left: -80px;
+                font-size: 11px;
+            }
+
+
+
+            #tag:before {
+                border: solid transparent;
+                content: ' ';
+                height: 0;
+                left: 50%;
+                margin-left: -5px;
+                position: absolute;
+                width: 0;
+                border-width: 10px;
+                border-bottom-color: #FA283D;
+                top: -20px;
+            }
+            .taskText {
+                fill:white;
+                text-anchor:middle;
+            }
+            .taskTextOutsideRight {
+                fill:black;
+                text-anchor:start;
+            }
+            .taskTextOutsideLeft {
+                fill:black;
+                text-anchor:end;
+            }

Configuration

+

Is it possible to adjust the margins for rendering the sequence diagram.

+

This is done by defining the sequenceConfig part of the configuration object. Read more about it here. How to use
the CLI is described in the mermaidCLI page.

+ +

mermaid CLI

+

Installing mermaid globally (npm install -g mermaid) will expose the mermaid command to your environment, allowing you to generate PNGs from any file containing mermaid markup via the command line.

+

Note: The mermaid command requires PhantomJS (version ^1.9.0) to be installed and available in your $PATH, or you can specify it's location with the -e option. For most environments, npm install -g phantomjs will satisfy this requirement.

+

Usage

+
$ mermaid --help
+
+Usage: mermaid [options] ...
+
+file    The mermaid description file to be rendered
+
+Options:
+  -s --svg             Output SVG instead of PNG (experimental)
+  -p --png             If SVG was selected, and you also want PNG, set this flag
+  -o --outputDir       Directory to save files, will be created automatically, defaults to `cwd`
+  -e --phantomPath     Specify the path to the phantomjs executable
+  -c --sequenceConfig  Specify the path to the file with the configuration to be applied in the sequence diagram
+  -h --help            Show this message
+  -v --verbose         Show logging
+  --version            Print version and quit
mermaid testGraph.mmd

Sequence diagram configuration

+

The --sequenceConfig option allows overriding the sequence diagram configuration. It could be useful to increase the width between actors, the notes width or the margin to fit some large texts that are not well rendered with the default configuration, for example.

+

The content of the file must be a JSON like this:

+

+{
+    "diagramMarginX": 100,
+    "diagramMarginY": 10,
+    "actorMargin": 150,
+    "width": 150,
+    "height": 65,
+    "boxMargin": 10,
+    "boxTextMargin": 5,
+    "noteMargin": 10,
+    "messageMargin": 35
+}

These properties will override the default values and if a property is not set in this object, it will left it empty and could raise an error. The current properties (measured in px) are:

+ +

CLI Known Issues

+ + +

Demos

+

Basic flowchart

+
%% Example diagram
+graph LR
+    A[Square Rect] -- Link text --> B((Circle))
+    A --> C(Round Rect)
+    B --> D{Rhombus}
+    C --> D
graph LR + A[Square Rect] -- Link text --> B((Circle)) + A --> C(Round Rect) + B --> D{Rhombus} + C --> D

Larger flowchart with some styling

+
%% Code for flowchart below
+graph TB
+    sq[Square shape] --> ci((Circle shape))
+
+    subgraph A subgraph
+        od>Odd shape]-- Two line<br>edge comment --> ro
+        di{Diamond with <br/> line break} -.-> ro(Rounded<br>square<br>shape)
+        di==>ro2(Rounded square shape)
+    end
+
+    %% Notice that no text in shape are added here instead that is appended further down
+    e --> od3>Really long text with linebreak<br>in an Odd shape]
+
+    %% Comments after double percent signs
+    e((Inner / circle<br>and some odd <br>special characters)) --> f(,.?!+-*ز)
+
+    cyr[Cyrillic]-->cyr2((Circle shape Начало));
+
+     classDef green fill:#9f6,stroke:#333,stroke-width:2px;
+     classDef orange fill:#f96,stroke:#333,stroke-width:4px;
+     class sq,e green
+     class di orange
graph TB + sq[Square shape] --> ci((Circle shape)) + + subgraph A subgraph + od>Odd shape]-- Two line<br>edge comment --> ro + di{Diamond with <br/> line break} -.-> ro(Rounded<br>square<br>shape) + di==>ro2(Rounded square shape) + end + + %% Notice that no text in shape are added here instead that is appended further down + e --> od3>Really long text with linebreak
in an Odd shape] + + %% Comments after double percent signs + e((Inner / circle
and some odd
special characters)) --> f(,.?!+-*ز) + + cyr[Cyrillic]-->cyr2((Circle shape Начало)); + + classDef green fill:#9f6,stroke:#333,stroke-width:2px; + classDef orange fill:#f96,stroke:#333,stroke-width:4px; + class sq,e green + class di orange

Basic sequence diagram

+
%% Sequence diagram code
+sequenceDiagram
+    Alice ->> Bob: Hello Bob, how are you?
+    Bob-->>John: How about you John?
+    Bob--x Alice: I am good thanks!
+    Bob-x John: I am good thanks!
+    Note right of John: Bob thinks a long<br/>long time, so long<br/>that the text does<br/>not fit on a row.
+
+    Bob-->Alice: Checking with John...
+    Alice->John: Yes... John, how are you?
sequenceDiagram + Alice->> Bob: Hello Bob, how are you? + Bob-->> John: How about you John? + Bob--x Alice: I am good thanks! + Bob-x John: I am good thanks! + + Note right of John: Bob thinks a long
long time, so long
that the text does
not fit on a row. + + Bob-->Alice: Checking with John... + Alice->John: Yes... John, how are you?

Loops, alt and opt

+
%% Sequence diagram code
+sequenceDiagram
+    loop Daily query
+        Alice->>Bob: Hello Bob, how are you?
+        alt is sick
+            Bob->>Alice: Not so good :(
+        else is well
+            Bob->>Alice: Feeling fresh like a daisy
+        end
+
+        opt Extra response
+            Bob->>Alice: Thanks for asking
+        end
+    end
sequenceDiagram + loop Daily query + Alice->>Bob: Hello Bob, how are you? + alt is sick + Bob->>Alice: Not so good :( + else is well + Bob->>Alice: Feeling fresh like a daisy + end + + opt Extra response + Bob->>Alice: Thanks for asking + end + end

Message to self in loop

+
%% Sequence diagram code
+sequenceDiagram
+    participant Alice
+    participant Bob
+    Alice->>John: Hello John, how are you?
+    loop Healthcheck
+        John->>John: Fight against hypochondria
+    end
+    Note right of John: Rational thoughts<br/>prevail...
+    John-->>Alice: Great!
+    John->>Bob: How about you?
+    Bob-->>John: Jolly good!
sequenceDiagram + participant Alice + participant Bob + Alice->>John: Hello John, how are you? + loop Healthcheck + John->>John: Fight against hypochondria + end + Note right of John: Rational thoughts
prevail... + John-->>Alice: Great! + John->>Bob: How about you? + Bob-->>John: Jolly good!
+

mermaidAPI

+

This is the api to be used when handling the integration with the web page instead of using the default integration
(mermaid.js).

+

The core of this api is the render function that given a graph definitionas text renders the graph/diagram and
returns a svg element for the graph. It is is then up to the user of the API to make use of the svg, either insert it
somewhere in the page or something completely different.

+

Configuration

+

These are the default options which can be overridden with the initialization call as in the example below:

+
mermaid.initialize({
+  flowchart:{
+     htmlLabels: false
+  }
+});

cloneCssStyles - This options controls whether or not the css rules should be copied into the generated svg
startOnLoad - This options controls whether or mermaid starts when the page loads

+

flowchart

+

The object containing configurations specific for flowcharts
htmlLabels - Flag for setting whether or not a html tag should be used for rendering labels
on the edges
useMaxWidth - Flag for setting whether or not a all available width should be used for
the diagram.

+

sequenceDiagram

+

The object containing configurations specific for sequence diagrams
diagramMarginX - margin to the right and left of the sequence diagram
diagramMarginY - margin to the over and under the sequence diagram
actorMargin - Margin between actors
width - Width of actor boxes
height - Height of actor boxes
boxMargin - Margin around loop boxes
boxTextMargin - margin around the text in loop/alt/opt boxes
noteMargin - margin around notes
messageMargin - Space between messages
mirrorActors - mirror actors under diagram
bottomMarginAdj - Depending on css styling this might need adjustment.
Prolongs the edge of the diagram downwards
useMaxWidth - when this flag is set the height and width is set to 100% and is then scaling with the
available space if not the absolute space required is used

+

gantt

+

The object containing configurations specific for gantt diagrams
titleTopMargin - margin top for the text over the gantt diagram
barHeight - the height of the bars in the graph
barGap - the margin between the different activities in the gantt diagram
topPadding - margin between title and gantt diagram and between axis and gantt diagram.
sidePadding - the space allocated for the section name to the left of the activities.
gridLineStartPadding - Vertical starting position of the grid lines
fontSize - font size ...
fontFamily - font family ...
numberSectionStyles - the number of alternating section styles
*axisFormatter
- formatting of the axis, this might need adjustment to match your locale and preferences

+

parse

+

Function that parses a mermaid diagram definition. If parsing fails the parseError callback is called and an error is
thrown and

+

version

+

Function returning version information

+

render

+

Function that renders an svg with a graph from a chart definition. Usage example below.

+
mermaidAPI.initialize({
+     startOnLoad:true
+ });
+ $(function(){
+     var graphDefinition = 'graph TB\na-->b';
+     var cb = function(svgGraph){
+         console.log(svgGraph);
+     };
+     mermaidAPI.render('id1',graphDefinition,cb);
+ });
+

Development

+

Updating the documentation

+

Getting the development environment up

+
    +
  1. Fork the gh-pages branch in the the mermaid repository
  2. +
  3. Do npm install
  4. +
+

Working with the documentation

+

The html files are generated from the source and the markdown files in the docs folder. The site generation is done
using the docker.js framework with the command below.

+
docker -i ../mermaid/ -x "*git*|*travis*|*bin*|*dist*|*node_modules*|*gulp*|*lib*|*editor*|*conf*|*scripts*|*test*|*htmlDocs*" --extras mermaid -w -o htmlDocs

Thus ... One important thing to remember. Do not edit the html files directly! Those changes will be overwritten
when the site is re-generated.

+

Committing the changes

+

Do a pull request to merge the changes to the site.

+

Things to be done in order to add a new diagram type

+

Step 1: Grammar & Parsing

+

Grammar

+

This would be to define a jison grammar for the new diagram type. That should start with a way to identify that the text in the mermaid tag is a diagram of that type. Create a new folder under diagrams for your new diagram type and a parser folder in it. This leads us to step 2.

+

For instance:

+ +

Store data found during parsing

+

There are some jison specific sub steps here where the parser stores the data encountered when parsing the diagram, this data is later used by the renderer. You can during the parsing call a object provided to the parser by the user of the parser. This object can be called during parsing for storing data.

+
statement
+    : 'participant' actor  { $$='actor'; }
+    | signal               { $$='signal'; }
+    | note_statement       { $$='note';  }
+    | 'title' message      { yy.setTitle($2);  }
+    ;

In the extract of the grammar above, it is defined that a call to the setTitle method in the data object will be done when parsing and the title keyword is encountered.

+

Note: Make sure that the parseError function for the parser is defined and calling mermaidPAI.parseError this way a common way of detecting parse errors is provided for the end-user.

+

For more info look in the example diagram type:

+

The yy object has the following function:

+
exports.parseError = function(err,hash){
+   mermaidAPI.parseError(err,hash);
+};

when parsing the yy object is initialized as per below:

+
    var parser;
+    parser = exampleParser.parser;
+    parser.yy = db;

Step 2: Rendering

+

Write a renderer that given the data found during parsing renders the diagram. To look at an example look at sequendeRenderer.js rather then the flowchart renderer as this is a more generic example.

+

Place the renderer in the diagram folder.

+

Step 3: Detection of the new diagram type

+

The second thing to do is to add the capability to detect the new new diagram to type to the detectType in utils.js. The detection should return a key for the new diagram type.

+

Step 4: The final piece - triggering the rendering

+

At this point when mermaid is trying to render the diagram, it will detect it as being of the new type but there will be no match when trying to render the diagram. To fix this add a new case in the switch statement in main.js:init this should match the diagram type returned from step number 2. The code in this new case statement should call the renderer for the diagram type with the data found by the parser as an argument.

+

Usage of the parser as a separate module

+

Setup

+
var graph = require('./graphDb');
+var flow = require('./parser/flow');
+flow.parser.yy = graph;

Parsing

+
flow.parser.parse(text);

Data extraction

+
// Javascript example
+graph.getDirection();
+graph.getVertices();
+graph.getEdges();

The parser is also exposed in the mermaid api by calling:

+
var parser = mermaid.getParser();

Note that the parse needs a graph object to store the data as per:

+
flow.parser.yy = graph;

Look at graphDb.js for more details on that object.

+ +

Upgrading to from version -0.4.0

+

Some of the interfaces has been upgraded.

+

Initialization

+

mermaid_config is no longer used. Instead a call to mermaid initialize is done as in the example below:

+

version 0.4.0

+
mermaid_config = {
+    startOnLoad:true
+    };

will look like below in version 0.5.0

+
mermaid.initialize({
+    startOnLoad:true
+    });
+ +
+
+
+ shell + ruby + python +
+
+
+ + diff --git a/dist/www/javascripts/all.js b/dist/www/javascripts/all.js new file mode 100644 index 000000000..ba3a4f910 --- /dev/null +++ b/dist/www/javascripts/all.js @@ -0,0 +1,143 @@ +!function(){if("ontouchstart"in window){var t,e,n,r,i,o,a={};t=function(t,e){return Math.abs(t[0]-e[0])>5||Math.abs(t[1]-e[1])>5},e=function(t){this.startXY=[t.touches[0].clientX,t.touches[0].clientY],this.threshold=!1},n=function(e){return this.threshold?!1:void(this.threshold=t(this.startXY,[e.touches[0].clientX,e.touches[0].clientY]))},r=function(e){if(!this.threshold&&!t(this.startXY,[e.changedTouches[0].clientX,e.changedTouches[0].clientY])){var n=e.changedTouches[0],r=document.createEvent("MouseEvents");r.initMouseEvent("click",!0,!0,window,0,n.screenX,n.screenY,n.clientX,n.clientY,!1,!1,!1,!1,0,null),r.simulated=!0,e.target.dispatchEvent(r)}},i=function(t){var e=Date.now(),n=e-a.time,r=t.clientX,i=t.clientY,s=[Math.abs(a.x-r),Math.abs(a.y-i)],u=o(t.target,"A")||t.target,c=u.nodeName,l="A"===c,h=window.navigator.standalone&&l&&t.target.getAttribute("href");return a.time=e,a.x=r,a.y=i,(!t.simulated&&(500>n||1500>n&&s[0]<50&&s[1]<50)||h)&&(t.preventDefault(),t.stopPropagation(),!h)?!1:(h&&(window.location=u.getAttribute("href")),void(u&&u.classList&&(u.classList.add("energize-focus"),window.setTimeout(function(){u.classList.remove("energize-focus")},150))))},o=function(t,e){for(var n=t;n!==document.body;){if(!n||n.nodeName===e)return n;n=n.parentNode}return null},document.addEventListener("touchstart",e,!1),document.addEventListener("touchmove",n,!1),document.addEventListener("touchend",r,!1),document.addEventListener("click",i,!0)}}(),/* +Copyright 2008-2013 Concur Technologies, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); you may +not use this file except in compliance with the License. You may obtain +a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. +*/ +function(t){"use strict";function e(e){if(e&&""!==e){$(".lang-selector a").removeClass("active"),$(".lang-selector a[data-language-name='"+e+"']").addClass("active");for(var n=0;n=1){var t=n(location.search).language;if(t)return t;if(-1!=jQuery.inArray(location.search.substr(1),u))return location.search.substr(1)}return!1}function o(t){var e=n(location.search);return e.language?(e.language=t,r(e)):t}function a(t){if(history){var e=window.location.hash;e&&(e=e.replace(/^#+/,"")),history.pushState({},"","?"+o(t)+"#"+e),localStorage.setItem("language",t)}}function s(t){var n=localStorage.getItem("language");u=t;var r=i();r?(e(r),localStorage.setItem("language",r)):e(null!==n&&-1!=jQuery.inArray(n,u)?n:u[0])}var u=[];t.setupLanguages=s,t.activateLanguage=e,$(function(){$(".lang-selector a").on("click",function(){var t=$(this).data("language-name");return a(t),e(t),!1}),window.onpopstate=function(){e(i())}})}(window),/** + * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 0.5.7 + * Copyright (C) 2014 Oliver Nightingale + * MIT Licensed + * @license + */ +function(){var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.5.7",/*! + * lunr.utils + * Copyright (C) 2014 Oliver Nightingale + */ +t.utils={},t.utils.warn=function(t){return function(e){t.console&&console.warn&&console.warn(e)}}(this),/*! + * lunr.EventEmitter + * Copyright (C) 2014 Oliver Nightingale + */ +t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),n=t;if("function"!=typeof e)throw new TypeError("last argument must be a function");n.forEach(function(t){this.hasHandler(t)||(this.events[t]=[]),this.events[t].push(e)},this)},t.EventEmitter.prototype.removeListener=function(t,e){if(this.hasHandler(t)){var n=this.events[t].indexOf(e);this.events[t].splice(n,1),this.events[t].length||delete this.events[t]}},t.EventEmitter.prototype.emit=function(t){if(this.hasHandler(t)){var e=Array.prototype.slice.call(arguments,1);this.events[t].forEach(function(t){t.apply(void 0,e)})}},t.EventEmitter.prototype.hasHandler=function(t){return t in this.events},/*! + * lunr.tokenizer + * Copyright (C) 2014 Oliver Nightingale + */ +t.tokenizer=function(t){if(!arguments.length||null==t||void 0==t)return[];if(Array.isArray(t))return t.map(function(t){return t.toLowerCase()});for(var e=t.toString().replace(/^\s+/,""),n=e.length-1;n>=0;n--)if(/\S/.test(e.charAt(n))){e=e.substring(0,n+1);break}return e.split(/(?:\s+|\-)/).filter(function(t){return!!t}).map(function(t){return t.toLowerCase()})},/*! + * lunr.Pipeline + * Copyright (C) 2014 Oliver Nightingale + */ +t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(e){var r=t.Pipeline.registeredFunctions[e];if(!r)throw new Error("Cannot load un-registered function: "+e);n.add(r)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e)+1;this._stack.splice(r,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);this._stack.splice(r,0,n)},t.Pipeline.prototype.remove=function(t){var e=this._stack.indexOf(t);this._stack.splice(e,1)},t.Pipeline.prototype.run=function(t){for(var e=[],n=t.length,r=this._stack.length,i=0;n>i;i++){for(var o=t[i],a=0;r>a&&(o=this._stack[a](o,i,t),void 0!==o);a++);void 0!==o&&e.push(o)}return e},t.Pipeline.prototype.reset=function(){this._stack=[]},t.Pipeline.prototype.toJSON=function(){return this._stack.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},/*! + * lunr.Vector + * Copyright (C) 2014 Oliver Nightingale + */ +t.Vector=function(){this._magnitude=null,this.list=void 0,this.length=0},t.Vector.Node=function(t,e,n){this.idx=t,this.val=e,this.next=n},t.Vector.prototype.insert=function(e,n){var r=this.list;if(!r)return this.list=new t.Vector.Node(e,n,r),this.length++;for(var i=r,o=r.next;void 0!=o;){if(en.idx?n=n.next:(r+=e.val*n.val,e=e.next,n=n.next);return r},t.Vector.prototype.similarity=function(t){return this.dot(t)/(this.magnitude()*t.magnitude())},/*! + * lunr.SortedSet + * Copyright (C) 2014 Oliver Nightingale + */ +t.SortedSet=function(){this.length=0,this.elements=[]},t.SortedSet.load=function(t){var e=new this;return e.elements=t,e.length=t.length,e},t.SortedSet.prototype.add=function(){Array.prototype.slice.call(arguments).forEach(function(t){~this.indexOf(t)||this.elements.splice(this.locationFor(t),0,t)},this),this.length=this.elements.length},t.SortedSet.prototype.toArray=function(){return this.elements.slice()},t.SortedSet.prototype.map=function(t,e){return this.elements.map(t,e)},t.SortedSet.prototype.forEach=function(t,e){return this.elements.forEach(t,e)},t.SortedSet.prototype.indexOf=function(t,e,n){var e=e||0,n=n||this.elements.length,r=n-e,i=e+Math.floor(r/2),o=this.elements[i];return 1>=r?o===t?i:-1:t>o?this.indexOf(t,i,n):o>t?this.indexOf(t,e,i):o===t?i:void 0},t.SortedSet.prototype.locationFor=function(t,e,n){var e=e||0,n=n||this.elements.length,r=n-e,i=e+Math.floor(r/2),o=this.elements[i];if(1>=r){if(o>t)return i;if(t>o)return i+1}return t>o?this.locationFor(t,i,n):o>t?this.locationFor(t,e,i):void 0},t.SortedSet.prototype.intersect=function(e){for(var n=new t.SortedSet,r=0,i=0,o=this.length,a=e.length,s=this.elements,u=e.elements;;){if(r>o-1||i>a-1)break;s[r]!==u[i]?s[r]u[i]&&i++:(n.add(s[r]),r++,i++)}return n},t.SortedSet.prototype.clone=function(){var e=new t.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},t.SortedSet.prototype.union=function(t){var e,n,r;return this.length>=t.length?(e=this,n=t):(e=t,n=this),r=e.clone(),r.add.apply(r,n.toArray()),r},t.SortedSet.prototype.toJSON=function(){return this.toArray()},/*! + * lunr.Index + * Copyright (C) 2014 Oliver Nightingale + */ +t.Index=function(){this._fields=[],this._ref="id",this.pipeline=new t.Pipeline,this.documentStore=new t.Store,this.tokenStore=new t.TokenStore,this.corpusTokens=new t.SortedSet,this.eventEmitter=new t.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},t.Index.prototype.on=function(){var t=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,t)},t.Index.prototype.off=function(t,e){return this.eventEmitter.removeListener(t,e)},t.Index.load=function(e){e.version!==t.version&&t.utils.warn("version mismatch: current "+t.version+" importing "+e.version);var n=new this;return n._fields=e.fields,n._ref=e.ref,n.documentStore=t.Store.load(e.documentStore),n.tokenStore=t.TokenStore.load(e.tokenStore),n.corpusTokens=t.SortedSet.load(e.corpusTokens),n.pipeline=t.Pipeline.load(e.pipeline),n},t.Index.prototype.field=function(t,e){var e=e||{},n={name:t,boost:e.boost||1};return this._fields.push(n),this},t.Index.prototype.ref=function(t){return this._ref=t,this},t.Index.prototype.add=function(e,n){var r={},i=new t.SortedSet,o=e[this._ref],n=void 0===n?!0:n;this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n.name]));r[n.name]=o,t.SortedSet.prototype.add.apply(i,o)},this),this.documentStore.set(o,i),t.SortedSet.prototype.add.apply(this.corpusTokens,i.toArray());for(var a=0;a0&&(r=1+Math.log(this.tokenStore.length/n)),this._idfCache[e]=r},t.Index.prototype.search=function(e){var n=this.pipeline.run(t.tokenizer(e)),r=new t.Vector,i=[],o=this._fields.reduce(function(t,e){return t+e.boost},0),a=n.some(function(t){return this.tokenStore.has(t)},this);if(!a)return[];n.forEach(function(e,n,a){var s=1/a.length*this._fields.length*o,u=this,c=this.tokenStore.expand(e).reduce(function(n,i){var o=u.corpusTokens.indexOf(i),a=u.idf(i),c=1,l=new t.SortedSet;if(i!==e){var h=Math.max(3,i.length-e.length);c=1/Math.log(h)}return o>-1&&r.insert(o,s*a*c),Object.keys(u.tokenStore.get(i)).forEach(function(t){l.add(t)}),n.union(l)},new t.SortedSet);i.push(c)},this);var s=i.reduce(function(t,e){return t.intersect(e)});return s.map(function(t){return{ref:t,score:r.similarity(this.documentVector(t))}},this).sort(function(t,e){return e.score-t.score})},t.Index.prototype.documentVector=function(e){for(var n=this.documentStore.get(e),r=n.length,i=new t.Vector,o=0;r>o;o++){var a=n.elements[o],s=this.tokenStore.get(a)[e].tf,u=this.idf(a);i.insert(this.corpusTokens.indexOf(a),s*u)}return i},t.Index.prototype.toJSON=function(){return{version:t.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),tokenStore:this.tokenStore.toJSON(),corpusTokens:this.corpusTokens.toJSON(),pipeline:this.pipeline.toJSON()}},t.Index.prototype.use=function(t){var e=Array.prototype.slice.call(arguments,1);e.unshift(this),t.apply(this,e)},/*! + * lunr.Store + * Copyright (C) 2014 Oliver Nightingale + */ +t.Store=function(){this.store={},this.length=0},t.Store.load=function(e){var n=new this;return n.length=e.length,n.store=Object.keys(e.store).reduce(function(n,r){return n[r]=t.SortedSet.load(e.store[r]),n},{}),n},t.Store.prototype.set=function(t,e){this.has(t)||this.length++,this.store[t]=e},t.Store.prototype.get=function(t){return this.store[t]},t.Store.prototype.has=function(t){return t in this.store},t.Store.prototype.remove=function(t){this.has(t)&&(delete this.store[t],this.length--)},t.Store.prototype.toJSON=function(){return{store:this.store,length:this.length}},/*! + * lunr.stemmer + * Copyright (C) 2014 Oliver Nightingale + * Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt + */ +t.stemmer=function(){var t={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},e={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},n="[^aeiou]",r="[aeiouy]",i=n+"[^aeiouy]*",o=r+"[aeiou]*",a="^("+i+")?"+o+i,s="^("+i+")?"+o+i+"("+o+")?$",u="^("+i+")?"+o+i+o+i,c="^("+i+")?"+r,l=new RegExp(a),h=new RegExp(u),f=new RegExp(s),d=new RegExp(c),p=/^(.+?)(ss|i)es$/,g=/^(.+?)([^s])s$/,m=/^(.+?)eed$/,y=/^(.+?)(ed|ing)$/,v=/.$/,b=/(at|bl|iz)$/,_=new RegExp("([^aeiouylsz])\\1$"),x=new RegExp("^"+i+r+"[^aeiouwxy]$"),w=/^(.+?[^aeiou])y$/,E=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,A=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,k=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,D=/^(.+?)(s|t)(ion)$/,S=/^(.+?)e$/,C=/ll$/,M=new RegExp("^"+i+r+"[^aeiouwxy]$"),T=function(n){var r,i,o,a,s,u,c;if(n.length<3)return n;if(o=n.substr(0,1),"y"==o&&(n=o.toUpperCase()+n.substr(1)),a=p,s=g,a.test(n)?n=n.replace(a,"$1$2"):s.test(n)&&(n=n.replace(s,"$1$2")),a=m,s=y,a.test(n)){var T=a.exec(n);a=l,a.test(T[1])&&(a=v,n=n.replace(a,""))}else if(s.test(n)){var T=s.exec(n);r=T[1],s=d,s.test(r)&&(n=r,s=b,u=_,c=x,s.test(n)?n+="e":u.test(n)?(a=v,n=n.replace(a,"")):c.test(n)&&(n+="e"))}if(a=w,a.test(n)){var T=a.exec(n);r=T[1],n=r+"i"}if(a=E,a.test(n)){var T=a.exec(n);r=T[1],i=T[2],a=l,a.test(r)&&(n=r+t[i])}if(a=A,a.test(n)){var T=a.exec(n);r=T[1],i=T[2],a=l,a.test(r)&&(n=r+e[i])}if(a=k,s=D,a.test(n)){var T=a.exec(n);r=T[1],a=h,a.test(r)&&(n=r)}else if(s.test(n)){var T=s.exec(n);r=T[1]+T[2],s=h,s.test(r)&&(n=r)}if(a=S,a.test(n)){var T=a.exec(n);r=T[1],a=h,s=f,u=M,(a.test(r)||s.test(r)&&!u.test(r))&&(n=r)}return a=C,s=h,a.test(n)&&s.test(n)&&(a=v,n=n.replace(a,"")),"y"==o&&(n=o.toLowerCase()+n.substr(1)),n};return T}(),t.Pipeline.registerFunction(t.stemmer,"stemmer"),/*! + * lunr.stopWordFilter + * Copyright (C) 2014 Oliver Nightingale + */ +t.stopWordFilter=function(e){return-1===t.stopWordFilter.stopWords.indexOf(e)?e:void 0},t.stopWordFilter.stopWords=new t.SortedSet,t.stopWordFilter.stopWords.length=119,t.stopWordFilter.stopWords.elements=["","a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"],t.Pipeline.registerFunction(t.stopWordFilter,"stopWordFilter"),/*! + * lunr.trimmer + * Copyright (C) 2014 Oliver Nightingale + */ +t.trimmer=function(t){return t.replace(/^\W+/,"").replace(/\W+$/,"")},t.Pipeline.registerFunction(t.trimmer,"trimmer"),/*! + * lunr.stemmer + * Copyright (C) 2014 Oliver Nightingale + * Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt + */ +t.TokenStore=function(){this.root={docs:{}},this.length=0},t.TokenStore.load=function(t){var e=new this;return e.root=t.root,e.length=t.length,e},t.TokenStore.prototype.add=function(t,e,n){var n=n||this.root,r=t[0],i=t.slice(1);return r in n||(n[r]={docs:{}}),0===i.length?(n[r].docs[e.ref]=e,void(this.length+=1)):this.add(i,e,n[r])},t.TokenStore.prototype.has=function(t){if(!t)return!1;for(var e=this.root,n=0;n (default options) + * $('#content').highlight('lorem'); + * + * // search for and highlight more terms at once + * // so you can save some time on traversing DOM + * $('#content').highlight(['lorem', 'ipsum']); + * $('#content').highlight('lorem ipsum'); + * + * // search only for entire word 'lorem' + * $('#content').highlight('lorem', { wordsOnly: true }); + * + * // don't ignore case during search of term 'lorem' + * $('#content').highlight('lorem', { caseSensitive: true }); + * + * // wrap every occurrance of term 'ipsum' in content + * // with + * $('#content').highlight('ipsum', { element: 'em', className: 'important' }); + * + * // remove default highlight + * $('#content').unhighlight(); + * + * // remove custom highlight + * $('#content').unhighlight({ element: 'em', className: 'important' }); + * + * + * Copyright (c) 2009 Bartek Szopka + * + * Licensed under MIT license. + * + */ +jQuery.extend({highlight:function(t,e,n,r){if(3===t.nodeType){var i=t.data.match(e);if(i){var o=document.createElement(n||"span");o.className=r||"highlight";var a=t.splitText(i.index);a.splitText(i[0].length);var s=a.cloneNode(!0);return o.appendChild(s),a.parentNode.replaceChild(o,a),1}}else if(1===t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName)&&(t.tagName!==n.toUpperCase()||t.className!==r))for(var u=0;u1e-4});e.length?(a.empty(),$.each(e,function(t,e){var n=document.getElementById(e.ref);a.append("
  • "+$(n).text()+"
  • ")}),r.call(this)):(a.html("
  • "),$(".search-results li").text('No Results Found for "'+this.value+'"'))}else i(),a.removeClass("visible")}function r(){this.value&&o.highlight(this.value,s)}function i(){o.unhighlight(s)}var o,a,s={element:"span",className:"search-highlight"},u=new lunr.Index;u.ref("id"),u.field("title",{boost:10}),u.field("body"),u.pipeline.add(lunr.trimmer,lunr.stopWordFilter),$(t),$(e)}(),/*! jQuery UI - v1.11.3 - 2015-02-12 + * http://jqueryui.com + * Includes: widget.js + * Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */ +function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(t){/*! + * jQuery UI Widget 1.11.3 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + * + * http://api.jqueryui.com/jQuery.widget/ + */ +var e=0,n=Array.prototype.slice;t.cleanData=function(e){return function(n){var r,i,o;for(o=0;null!=(i=n[o]);o++)try{r=t._data(i,"events"),r&&r.remove&&t(i).triggerHandler("remove")}catch(a){}e(n)}}(t.cleanData),t.widget=function(e,n,r){var i,o,a,s,u={},c=e.split(".")[0];return e=e.split(".")[1],i=c+"-"+e,r||(r=n,n=t.Widget),t.expr[":"][i.toLowerCase()]=function(e){return!!t.data(e,i)},t[c]=t[c]||{},o=t[c][e],a=t[c][e]=function(t,e){return this._createWidget?void(arguments.length&&this._createWidget(t,e)):new a(t,e)},t.extend(a,o,{version:r.version,_proto:t.extend({},r),_childConstructors:[]}),s=new n,s.options=t.widget.extend({},s.options),t.each(r,function(e,r){return t.isFunction(r)?void(u[e]=function(){var t=function(){return n.prototype[e].apply(this,arguments)},i=function(t){return n.prototype[e].apply(this,t)};return function(){var e,n=this._super,o=this._superApply;return this._super=t,this._superApply=i,e=r.apply(this,arguments),this._super=n,this._superApply=o,e}}()):void(u[e]=r)}),a.prototype=t.widget.extend(s,{widgetEventPrefix:o?s.widgetEventPrefix||e:e},u,{constructor:a,namespace:c,widgetName:e,widgetFullName:i}),o?(t.each(o._childConstructors,function(e,n){var r=n.prototype;t.widget(r.namespace+"."+r.widgetName,a,n._proto)}),delete o._childConstructors):n._childConstructors.push(a),t.widget.bridge(e,a),a},t.widget.extend=function(e){for(var r,i,o=n.call(arguments,1),a=0,s=o.length;s>a;a++)for(r in o[a])i=o[a][r],o[a].hasOwnProperty(r)&&void 0!==i&&(e[r]=t.isPlainObject(i)?t.isPlainObject(e[r])?t.widget.extend({},e[r],i):t.widget.extend({},i):i);return e},t.widget.bridge=function(e,r){var i=r.prototype.widgetFullName||e;t.fn[e]=function(o){var a="string"==typeof o,s=n.call(arguments,1),u=this;return a?this.each(function(){var n,r=t.data(this,i);return"instance"===o?(u=r,!1):r?t.isFunction(r[o])&&"_"!==o.charAt(0)?(n=r[o].apply(r,s),n!==r&&void 0!==n?(u=n&&n.jquery?u.pushStack(n.get()):n,!1):void 0):t.error("no such method '"+o+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; attempted to call method '"+o+"'")}):(s.length&&(o=t.widget.extend.apply(null,[o].concat(s))),this.each(function(){var e=t.data(this,i);e?(e.option(o||{}),e._init&&e._init()):t.data(this,i,new r(o,this))})),u}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
    ",options:{disabled:!1,create:null},_createWidget:function(n,r){r=t(r||this.defaultElement||this)[0],this.element=t(r),this.uuid=e++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),r!==this&&(t.data(r,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===r&&this.destroy()}}),this.document=t(r.style?r.ownerDocument:r.document||r),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),n),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:t.noop,_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:t.noop,widget:function(){return this.element},option:function(e,n){var r,i,o,a=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(a={},r=e.split("."),e=r.shift(),r.length){for(i=a[e]=t.widget.extend({},this.options[e]),o=0;o",{id:u+e,"class":u}).append(r._nestElements(t(this),e)),r.element.append(n),t(this).nextUntil(this.nodeName.toLowerCase()).each(function(){0===t(this).find(r.options.selectors).length?t(this).filter(r.options.selectors).each(function(){t(this).is(o)||r._appendSubheaders.call(this,r,n)}):t(this).find(r.options.selectors).each(function(){t(this).is(o)||r._appendSubheaders.call(this,r,n)})}))})):void r.element.addClass(s)},_setActiveElement:function(t){var n=this,r=e.location.hash.substring(1),i=n.element.find("li[data-unique='"+r+"']");return r.length?(n.element.find("."+n.focusClass).removeClass(n.focusClass),i.addClass(n.focusClass),n.options.showAndHide&&i.click()):(n.element.find("."+n.focusClass).removeClass(n.focusClass),!r.length&&t&&n.options.highlightDefault&&n.element.find(d).first().addClass(n.focusClass)),n},_nestElements:function(e,n){var r,i,o;return r=t.grep(this.items,function(t){return t===e.text()}),this.items.push(r.length?e.text()+n:e.text()),o=this._generateHashValue(r,e,n),i=t("
  • ",{"class":f,"data-unique":o}).append(t("",{text:e.text()})),e.before(t("
    ",{name:o,"data-unique":o})),i},_generateHashValue:function(t,e,n){var r="",i=this.options.hashGenerator;if("pretty"===i){for(r=e.text().toLowerCase().replace(/\s/g,"-"),r=r.replace(/[^\x00-\x7F]/g,"");r.indexOf("--")>-1;)r=r.replace(/--/g,"-");for(;r.indexOf(":-")>-1;)r=r.replace(/:-/g,"-")}else r="function"==typeof i?i(e.text(),e):e.text().replace(/\s/g,"");return t.length&&(r+=""+n),r},_appendSubheaders:function(e,n){var r=t(this).index(e.options.selectors),i=t(e.options.selectors).eq(r-1),o=+t(this).prop("tagName").charAt(1),a=+i.prop("tagName").charAt(1);a>o?e.element.find(h+"[data-tag="+o+"]").last().append(e._nestElements(t(this),r)):o===a?n.find(d).last().after(e._nestElements(t(this),r)):n.find(d).last().after(t("