mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-15 05:19:58 +02:00
Added support for nested subgraphs in grammar, part 1 of issue #161
This commit is contained in:
@@ -29,7 +29,7 @@ exports.addVertex = function (id, text, type, style) {
|
||||
vertices[id] = {id: id, styles: [], classes:[]};
|
||||
}
|
||||
if (typeof text !== 'undefined') {
|
||||
vertices[id].text = text;
|
||||
vertices[id].text = text.trim();
|
||||
}
|
||||
if (typeof type !== 'undefined') {
|
||||
vertices[id].type = type;
|
||||
@@ -59,7 +59,7 @@ exports.addLink = function (start, end, type, linktext) {
|
||||
linktext = type.text;
|
||||
|
||||
if (typeof linktext !== 'undefined') {
|
||||
edge.text = linktext;
|
||||
edge.text = linktext.trim();
|
||||
}
|
||||
|
||||
if (typeof type !== 'undefined') {
|
||||
|
@@ -17,7 +17,7 @@
|
||||
"click" return 'CLICK';
|
||||
"graph" return 'GRAPH';
|
||||
"subgraph" return 'subgraph';
|
||||
"end" return 'end';
|
||||
"end"\s* return 'end';
|
||||
"LR" return 'DIR';
|
||||
"RL" return 'DIR';
|
||||
"TB" return 'DIR';
|
||||
@@ -216,9 +216,9 @@ statement
|
||||
{$$=[];}
|
||||
| clickStatement separator
|
||||
{$$=[];}
|
||||
| subgraph text separator document end separator
|
||||
| subgraph text separator document end
|
||||
{yy.addSubGraph($4,$2);}
|
||||
| subgraph separator document end separator
|
||||
| subgraph separator document end
|
||||
{yy.addSubGraph($3,undefined);}
|
||||
;
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@@ -357,6 +357,17 @@ describe('when parsing ',function(){
|
||||
expect(edges[0].type).toBe('arrow');
|
||||
});
|
||||
|
||||
it('should handle nested subgraphs',function(){
|
||||
var str = 'graph TD\n' +
|
||||
'A-->B\n' +
|
||||
'subgraph myTitle\n\n' +
|
||||
' c-->d \n\n' +
|
||||
' subgraph inner\n\n e-->f \n end \n\n' +
|
||||
'end\n';
|
||||
var res = flow.parser.parse(str);
|
||||
|
||||
});
|
||||
|
||||
it('should handle subgraphs',function(){
|
||||
var res = flow.parser.parse('graph TD\nA-->B\nsubgraph myTitle\nc-->d\nend;');
|
||||
|
||||
|
@@ -38,6 +38,7 @@ module.exports.draw = function (text, id) {
|
||||
var h = taskArray.length * (conf.barHeight + conf.barGap) + 2 * conf.topPadding;
|
||||
|
||||
elem.style.height = h + 'px';
|
||||
elem.height = h;
|
||||
var svg = d3.select('#' + id);
|
||||
|
||||
// http://codepen.io/anon/pen/azLvWR
|
||||
|
Reference in New Issue
Block a user