Fix of broken tests

This commit is contained in:
knsv 2015-10-04 19:30:53 +02:00
parent c5d41c5a21
commit 122274bf52
9 changed files with 879 additions and 809 deletions

1577
dist/mermaid.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -38069,6 +38069,10 @@ exports.encodeEntities = function(text){
});
//txt = txt.replace(/fa:fa[\w\-]+/g,function(s,t,u){
// return 'fa:¢';
//});
return txt;
};
@ -38085,6 +38089,8 @@ exports.decodeEntities = function(text){
return ';';
});
return txt;
};
/**

View File

@ -212,7 +212,23 @@ graph LR
id1["This is the (text) in the box"]
```
### Another possibility is to use the entity codes
### Entity codes to escape characters
It is possible to escape characters using the syntax examplified here.
The flowchart defined by the following code:
```
graph LR
A["A double quote:#quot;"] -->B["A dec char:#9829;"]
```
This would render to the diagram below:
```mermaid
graph LR
A["A double quote:#quot;"] -->B["A dec char:#9829;"]
```
## Subgraphs
```

View File

@ -86,9 +86,11 @@ 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);
};

View File

@ -45,6 +45,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){
@ -65,7 +66,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;

View File

@ -28,7 +28,7 @@ var ganttParser = require('./diagrams/gantt/parser/gantt');
var ganttDb = require('./diagrams/gantt/ganttDb');
var d3 = require('./d3');
var nextId = 0;
var log = require('./logger').create();
/**
* ## Configuration
@ -42,6 +42,15 @@ var log = require('./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
*/
@ -216,6 +225,8 @@ var config = {
}
};
var log = require('./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
@ -440,7 +451,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]] = {};
@ -454,6 +465,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);

View File

@ -21,20 +21,11 @@ var log = require('./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";

View File

@ -8,19 +8,6 @@ describe('when detecting chart type ',function() {
});
it('should handle a sequence defintion', function () {
str = 'sequence TB\nbfs1:queue';
var type = utils.detectType(str);
expect(type).toBe('sequence');
});
it('should handle a sequence defintion with leading spaces', function () {
str = ' sequence TB\nbfs1:queue';
var type = utils.detectType(str);
expect(type).toBe('sequence');
});
it('should handle a graph defintion', function () {
str = 'graph TB\nbfs1:queue';
@ -40,12 +27,6 @@ describe('when detecting chart type ',function() {
var type = utils.detectType(str);
expect(type).toBe('graph');
});
it('should handle a sequence defintion with leading spaces and newline', function () {
str = ' \n sequence TB\nbfs1:queue';
var type = utils.detectType(str);
expect(type).toBe('sequence');
});
});
describe('when cloning CSS ',function() {

View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="../../dist/mermaid.css"/>
<script src="../../dist/mermaid.js"></script>
<style>
body{
background-color: #89896f;
}
</style>
</head>
<body>
<h1>The diagrams below have leading comments</h1>
<div class="mermaid" id="i211">
%% Example diagram
graph LR
A["A double quote:#quot;"] -->B["A dec char:#9829;"]
B -->C["#9829; ;^; #60;"]
</div>
<div class="mermaid" id="i211">
sequenceDiagram
Ali#45;ce->>John: Hello John, how are you? #60;
John-->>Alice: Great!#quot;
</div>
</body>
</html>