Skip to content

Commit

Permalink
New version
Browse files Browse the repository at this point in the history
  • Loading branch information
knsv committed Oct 4, 2015
1 parent 8258fb0 commit a611ff3
Show file tree
Hide file tree
Showing 17 changed files with 140 additions and 84 deletions.
12 changes: 11 additions & 1 deletion dist/mermaid.js
Original file line number Diff line number Diff line change
Expand Up @@ -38070,6 +38070,15 @@ exports.version = function(){
exports.encodeEntities = function(text){
var txt = text;

txt = txt.replace(/style.*:\S*#.*;/g,function(s,t,u){
var innerTxt = s.substring(0,s.length-1);
return innerTxt;
});
txt = txt.replace(/classDef.*:\S*#.*;/g,function(s,t,u){
var innerTxt = s.substring(0,s.length-1);
return innerTxt;
});

txt = txt.replace(/#\w+\;/g,function(s,t,u){
var innerTxt = s.substring(1,s.length-1);

Expand Down Expand Up @@ -38150,7 +38159,7 @@ var render = function(id, txt, cb, container){
.append('g');
}


window.txt = txt;
txt = exports.encodeEntities(txt);
//console.warn('mermaid encode: ');
//console.warn(txt);
Expand All @@ -38160,6 +38169,7 @@ var render = function(id, txt, cb, container){
var classes = {};
switch(graphType){
case 'graph':

flowRenderer.setConf(config.flowchart);
flowRenderer.draw(txt, id, false);
if(config.cloneCssStyles){
Expand Down
4 changes: 2 additions & 2 deletions dist/mermaid.min.js

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion dist/mermaid.slim.js
Original file line number Diff line number Diff line change
Expand Up @@ -28854,6 +28854,15 @@ exports.version = function(){
exports.encodeEntities = function(text){
var txt = text;

txt = txt.replace(/style.*:\S*#.*;/g,function(s,t,u){
var innerTxt = s.substring(0,s.length-1);
return innerTxt;
});
txt = txt.replace(/classDef.*:\S*#.*;/g,function(s,t,u){
var innerTxt = s.substring(0,s.length-1);
return innerTxt;
});

txt = txt.replace(/#\w+\;/g,function(s,t,u){
var innerTxt = s.substring(1,s.length-1);

Expand Down Expand Up @@ -28934,7 +28943,7 @@ var render = function(id, txt, cb, container){
.append('g');
}


window.txt = txt;
txt = exports.encodeEntities(txt);
//console.warn('mermaid encode: ');
//console.warn(txt);
Expand All @@ -28944,6 +28953,7 @@ var render = function(id, txt, cb, container){
var classes = {};
switch(graphType){
case 'graph':

flowRenderer.setConf(config.flowchart);
flowRenderer.draw(txt, id, false);
if(config.cloneCssStyles){
Expand Down
4 changes: 2 additions & 2 deletions dist/mermaid.slim.min.js

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion dist/mermaidAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -37355,6 +37355,15 @@ exports.version = function(){
exports.encodeEntities = function(text){
var txt = text;

txt = txt.replace(/style.*:\S*#.*;/g,function(s,t,u){
var innerTxt = s.substring(0,s.length-1);
return innerTxt;
});
txt = txt.replace(/classDef.*:\S*#.*;/g,function(s,t,u){
var innerTxt = s.substring(0,s.length-1);
return innerTxt;
});

txt = txt.replace(/#\w+\;/g,function(s,t,u){
var innerTxt = s.substring(1,s.length-1);

Expand Down Expand Up @@ -37435,7 +37444,7 @@ var render = function(id, txt, cb, container){
.append('g');
}


window.txt = txt;
txt = exports.encodeEntities(txt);
//console.warn('mermaid encode: ');
//console.warn(txt);
Expand All @@ -37445,6 +37454,7 @@ var render = function(id, txt, cb, container){
var classes = {};
switch(graphType){
case 'graph':

flowRenderer.setConf(config.flowchart);
flowRenderer.draw(txt, id, false);
if(config.cloneCssStyles){
Expand Down
14 changes: 12 additions & 2 deletions dist/mermaidAPI.slim.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mermaidAPI.slim.min.js

Large diffs are not rendered by default.

53 changes: 35 additions & 18 deletions dist/www/javascripts/lib/mermaid.js
Original file line number Diff line number Diff line change
Expand Up @@ -37451,6 +37451,7 @@ module.exports.mermaidAPI = mermaidAPI;
* @param nodes a css selector or an array of nodes
*/
var init = function () {
var conf= mermaidAPI.getConfig();
log.debug('Starting rendering diagrams');
var nodes;
if(arguments.length >= 2){
Expand All @@ -37471,7 +37472,6 @@ var init = function () {
callback = arguments[arguments.length-1];
log.debug('Callback function found');
}else{
var conf= mermaidAPI.getConfig();
if(typeof conf.mermaid !== 'undefined'){
if(typeof conf.mermaid.callback === 'function'){
callback = conf.mermaid.callback;
Expand Down Expand Up @@ -37775,10 +37775,12 @@ Logger.levels = {
warn: 3,
error: 4,
fatal: 5,
default:1
default:5
};

exports.create = function(type, options) {
exports.setLogLevel = function(level){
Logger.levels.default = level;
}
exports.create = function(options) {
return new Logger(options);
};
}).call(this,_dereq_("1YiZ5S"))
Expand Down Expand Up @@ -37814,7 +37816,7 @@ var ganttParser = _dereq_('./diagrams/gantt/parser/gantt');
var ganttDb = _dereq_('./diagrams/gantt/ganttDb');
var d3 = _dereq_('./d3');
var nextId = 0;
var log = _dereq_('./logger').create();


/**
* ## Configuration
Expand All @@ -37828,6 +37830,15 @@ var log = _dereq_('./logger').create();
* ```
*/
var config = {
/**
* logLevel , decides the amount of logging to be used.
* * debug: 1
* * info: 2
* * warn: 3
* * error: 4
* * fatal: 5
*/
logLevel: 3,
/**
* **cloneCssStyles** - This options controls whether or not the css rules should be copied into the generated svg
*/
Expand Down Expand Up @@ -38002,6 +38013,8 @@ var config = {
}
};

var log = _dereq_('./logger').create({level:config.logLevel});

/**
* ## parse
* Function that parses a mermaid diagram definition. If parsing fails the parseError callback is called and an error is
Expand Down Expand Up @@ -38057,7 +38070,14 @@ exports.version = function(){
exports.encodeEntities = function(text){
var txt = text;

txt = txt.replace(/#\w*;?/g,function(s,t,u){
txt = txt.replace(/[style|classDef].*:\S*#.*;/g,function(s,t,u){

var innerTxt = s.substring(0,s.length-1);
return innerTxt;

});

txt = txt.replace(/#\w+\;/g,function(s,t,u){
var innerTxt = s.substring(1,s.length-1);

var isInt = /^\+?\d+$/.test(innerTxt);
Expand Down Expand Up @@ -38137,7 +38157,7 @@ var render = function(id, txt, cb, container){
.append('g');
}


window.txt = txt;
txt = exports.encodeEntities(txt);
//console.warn('mermaid encode: ');
//console.warn(txt);
Expand All @@ -38147,6 +38167,7 @@ var render = function(id, txt, cb, container){
var classes = {};
switch(graphType){
case 'graph':

flowRenderer.setConf(config.flowchart);
flowRenderer.draw(txt, id, false);
if(config.cloneCssStyles){
Expand Down Expand Up @@ -38184,6 +38205,10 @@ var render = function(id, txt, cb, container){
break;
}

d3.select('#d'+id).selectAll('foreignobject div').attr('xmlns','http://www.w3.org/1999/xhtml');



// Fix for when the base tag is used
var svgCode = d3.select('#d'+id).node().innerHTML.replace(/url\(#arrowhead/g,'url('+ window.location.protocol+'//'+location.host+location.pathname +'#arrowhead','g');

Expand Down Expand Up @@ -38226,7 +38251,7 @@ var setConf = function(cnf){

var j;
for(j=0;j<lvl2Keys.length;j++) {
//log.debug('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j]);
log.debug('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j]);
if(typeof config[lvl1Keys[i]] === 'undefined'){

config[lvl1Keys[i]] = {};
Expand All @@ -38240,6 +38265,7 @@ var setConf = function(cnf){
}
};
exports.initialize = function(options){
log.debug('Initializing mermaidAPI');
// Update default config with options supplied at initialization
if(typeof options === 'object'){
setConf(options);
Expand Down Expand Up @@ -38292,20 +38318,11 @@ var log = _dereq_('./logger').create();
* @returns {string} A graph definition key
*/
module.exports.detectType = function(text,a){
text = text.replace(/^\s*%%.*\n/g,'\n');
if(text.match(/^\s*sequenceDiagram/)){
return "sequenceDiagram";
}

if(text.match(/^\s*sequence/)){
/* ```mermaid
graph TB
a-->b
b-->c
```
*/
return "sequence";
}

if(text.match(/^\s*digraph/)) {
//log.debug('Detected dot syntax');
return "dotGraph";
Expand Down
3 changes: 2 additions & 1 deletion gulp/tasks/release.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var gulp = require('gulp');
var bump = require('gulp-bump');

gulp.task('bump', function(){
gulp.src('./bw.json')
Expand Down Expand Up @@ -28,7 +29,7 @@ gulp.task('tag', function() {

function inc(importance) {
// get all the files to bump version in
return gulp.src(['./package.json', './bower.json'])
return gulp.src(['./package.json'])
// bump the version number in those files
.pipe(bump({type: importance}))
// save it back to filesystem
Expand Down
22 changes: 13 additions & 9 deletions lib/phantomscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,19 @@ function executeInPage(data) {
el.appendChild(elContent)

document.body.appendChild(el)

if(typeof sequenceConfig !== undefined && sequenceConfig !== 'undefined'){
sc = document.createElement("script")
scContent = document.createTextNode('mermaid.sequenceConfig = JSON.parse(' + JSON.stringify(sequenceConfig) + ');')
sc.appendChild(scContent)
mermaid.initialize({
sequenceDiagram:{useMaxWidth:false}
});

document.body.appendChild(sc)
if(typeof sequenceConfig !== undefined && sequenceConfig !== 'undefined'){
//sc = document.createElement("script")
//scContent = document.createTextNode('mermaid.sequenceConfig = JSON.parse(' + JSON.stringify(sequenceConfig) + ');')
//sc.appendChild(scContent)

//document.body.appendChild(sc)
mermaid.initialize({
sequenceDiagram:JSON.parse(sequenceConfig)
});
}

if(typeof ganttConfig !== undefined && ganttConfig !== 'undefined'){
Expand All @@ -250,9 +256,7 @@ function executeInPage(data) {
document.body.appendChild(sc)
}

mermaid.initialize({
sequenceDiagram:{useMaxWidth:false}
});

mermaid.init();

svg = document.querySelector('svg')
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mermaid",
"version": "0.5.1",
"version": "0.5.2",
"description": "Markdownish syntax for generating flowcharts, sequence diagrams and gantt charts.",
"main": "src/mermaid.js",
"keywords": [
Expand All @@ -15,8 +15,8 @@
},
"scripts": {
"watch": "watchify src/mermaid.js -o dist/mermaid.js",
"doc" : "rm -r build;rm -r dist/www;gulp vartree;cp dist/www/all.html ../mermaid-pages/index.html;cp dist/mermaid.js ../mermaid-pages/javascripts/lib;cp dist/mermaid.forest.css ../mermaid-pages/stylesheets",
"test" : "./node_modules/.bin/gulp dist && ./node_modules/.bin/gulp test"
"doc": "rm -r build;rm -r dist/www;gulp vartree;cp dist/www/all.html ../mermaid-pages/index.html;cp dist/mermaid.js ../mermaid-pages/javascripts/lib;cp dist/mermaid.forest.css ../mermaid-pages/stylesheets",
"test": "./node_modules/.bin/gulp dist && ./node_modules/.bin/gulp test"
},
"repository": {
"type": "git",
Expand Down
12 changes: 11 additions & 1 deletion src/mermaidAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,15 @@ exports.version = function(){
exports.encodeEntities = function(text){
var txt = text;

txt = txt.replace(/style.*:\S*#.*;/g,function(s,t,u){
var innerTxt = s.substring(0,s.length-1);
return innerTxt;
});
txt = txt.replace(/classDef.*:\S*#.*;/g,function(s,t,u){
var innerTxt = s.substring(0,s.length-1);
return innerTxt;
});

txt = txt.replace(/#\w+\;/g,function(s,t,u){
var innerTxt = s.substring(1,s.length-1);

Expand Down Expand Up @@ -362,7 +371,7 @@ var render = function(id, txt, cb, container){
.append('g');
}


window.txt = txt;
txt = exports.encodeEntities(txt);
//console.warn('mermaid encode: ');
//console.warn(txt);
Expand All @@ -372,6 +381,7 @@ var render = function(id, txt, cb, container){
var classes = {};
switch(graphType){
case 'graph':

flowRenderer.setConf(config.flowchart);
flowRenderer.draw(txt, id, false);
if(config.cloneCssStyles){
Expand Down
9 changes: 0 additions & 9 deletions test/examples/leadingComments.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,5 @@ <h1>The diagrams below have leading comments</h1>
Ali#45;ce->>John: Hello John, how are you? #60;
John-->>Alice: Great!#quot;
</div>
<div class="mermaid" id="i211">
graph LR;
A[Hard edge]-->|Link text|B(Round edge);
B-->C{Decision};
C-->|One|D[Result one];
C-->|Two|E[Result two];
classDef pink fill:#f9f,stroke:#333,stroke-width:4px;
class C pink;
</div>
</body>
</html>
5 changes: 3 additions & 2 deletions test/sconf.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"diagramMarginY": 10,
"actorMargin": 50,
"width": 150,
"height": 165,
"height": 15,
"boxMargin": 10,
"boxTextMargin": 5,
"noteMargin": 10,
"messageMargin": 35
"messageMargin": 35,
"mirrorActors":false
}

0 comments on commit a611ff3

Please sign in to comment.