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:
commit
8906ee8097
24
README.md
24
README.md
|
@ -21,7 +21,7 @@ would render this lovely chart:
|
||||||
|
|
||||||
![Example 1](http://www.sveido.com/mermaid/img/ex1.png)
|
![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
|
#Installation
|
||||||
|
|
||||||
Either use the bower package manager as per below:
|
Either use the bower package manager as per below:
|
||||||
|
@ -251,5 +251,27 @@ click nodeId callback
|
||||||
* nodeId is the id of the node
|
* 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.
|
* 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
|
# 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!
|
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!
|
||||||
|
|
|
@ -3,7 +3,6 @@ var flow = require('./parser/flow');
|
||||||
var utils = require('./utils');
|
var utils = require('./utils');
|
||||||
var seq = require('./sequenceRenderer');
|
var seq = require('./sequenceRenderer');
|
||||||
var he = require('he');
|
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.
|
* Function that adds the vertices found in the graph definition to the graph to be rendered.
|
||||||
|
@ -278,7 +277,6 @@ var init = function () {
|
||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
var txt = element.innerHTML;
|
var txt = element.innerHTML;
|
||||||
|
|
||||||
txt = txt.replace(/>/g,'>');
|
txt = txt.replace(/>/g,'>');
|
||||||
txt = txt.replace(/</g,'<');
|
txt = txt.replace(/</g,'<');
|
||||||
txt = he.decode(txt).trim();
|
txt = he.decode(txt).trim();
|
||||||
|
|
|
@ -23,7 +23,7 @@ describe('when using main and ',function() {
|
||||||
div = document.createElement('div');
|
div = document.createElement('div');
|
||||||
mermaid_config ={startOnLoad : false};
|
mermaid_config ={startOnLoad : false};
|
||||||
main = rewire('./main');
|
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 () {
|
it('should not call start anything with an empty document', function () {
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,15 @@ describe('when parsing ',function(){
|
||||||
|
|
||||||
expect(edges[0].type).toBe('arrow_cross');
|
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(){
|
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;');
|
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'].type).toBe('round');
|
||||||
expect(vert['C'].text).toBe('Chimpansen hoppar åäö <br> - ÅÄÖ');
|
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(){
|
it('should handle a single node',function(){
|
||||||
// Silly but syntactically correct
|
// Silly but syntactically correct
|
||||||
var res = flow.parser.parse('graph TD;A;');
|
var res = flow.parser.parse('graph TD;A;');
|
||||||
|
|
Loading…
Reference in New Issue