Merge remote-tracking branch 'origin/master'

Conflicts:
	bower.json
	dist/mermaid.full.js
	dist/mermaid.full.min.js
	dist/mermaid.slim.js
	dist/mermaid.slim.min.js
	src/main.js
This commit is contained in:
knsv 2014-12-01 20:43:49 +01:00
commit 8906ee8097
4 changed files with 40 additions and 4 deletions

View File

@ -21,7 +21,7 @@ would render this lovely chart:
![Example 1](http://www.sveido.com/mermaid/img/ex1.png)
A simple page with a live example can be seen [here](http://www.sveido.com/mermaid/simpleExample.html). You can also look at mermaid in action using [jsbin](http://jsbin.com/faxunexeku/1/edit?html,output).
#Installation
Either use the bower package manager as per below:
@ -251,5 +251,27 @@ click nodeId callback
* nodeId is the id of the node
* callback is the name of a javascript function defined on the page displaying the graph, the function will be called with the nodeId as parameter.
## Usage of the parser as a seperate module
### Setup
```
var graph = require('./graphDb');
var flow = require('./parser/flow');
flow.parser.yy = graph;
```
### Parsing
```
flow.parser.parse(text);
```
### Data extraction
```
graph.getDirection();
graph.getVertices();
graph.getEdges();
```
# Credits
Many thanks to the [d3](http://d3js.org/) and [dagre-d3](https://github.com/cpettitt/dagre-d3) projects for providing the graphical layout and drawing libraries!

View File

@ -3,7 +3,6 @@ var flow = require('./parser/flow');
var utils = require('./utils');
var seq = require('./sequenceRenderer');
var he = require('he');
//var dagreD3 = require('dagre-d3');
/**
* Function that adds the vertices found in the graph definition to the graph to be rendered.
@ -278,7 +277,6 @@ var init = function () {
cnt++;
var txt = element.innerHTML;
txt = txt.replace(/>/g,'>');
txt = txt.replace(/</g,'&lt;');
txt = he.decode(txt).trim();

View File

@ -23,7 +23,7 @@ describe('when using main and ',function() {
div = document.createElement('div');
mermaid_config ={startOnLoad : false};
main = rewire('./main');
expect(main.version()).toBe('0.2.6');
expect(main.version()).toBe('0.2.8');
});
it('should not call start anything with an empty document', function () {

View File

@ -79,7 +79,15 @@ describe('when parsing ',function(){
expect(edges[0].type).toBe('arrow_cross');
});
it('should handle text on edges with space CAPS',function(){
var res = flow.parser.parse('graph TD;A--x|text including CAPS space|B;');
var vert = flow.parser.yy.getVertices();
var edges = flow.parser.yy.getEdges();
expect(edges[0].type).toBe('arrow_cross');
});
it('should handle multi-line text',function(){
var res = flow.parser.parse('graph TD;A--o|text space|B;\n B-->|more text with space|C;');
@ -173,7 +181,15 @@ describe('when parsing ',function(){
expect(vert['C'].type).toBe('round');
expect(vert['C'].text).toBe('Chimpansen hoppar åäö <br> - ÅÄÖ');
});
it('should handle text in vertices with CAPS',function(){
var res = flow.parser.parse('graph TD;A-->C(some CAPS);');
var vert = flow.parser.yy.getVertices();
var edges = flow.parser.yy.getEdges();
expect(vert['C'].type).toBe('round');
expect(vert['C'].text).toBe('some CAPS');
});
it('should handle a single node',function(){
// Silly but syntactically correct
var res = flow.parser.parse('graph TD;A;');