mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-08 01:56:42 +02:00
Fix of broken tests
This commit is contained in:
1577
dist/mermaid.js
vendored
1577
dist/mermaid.js
vendored
File diff suppressed because it is too large
Load Diff
6
dist/www/javascripts/lib/mermaid.js
vendored
6
dist/www/javascripts/lib/mermaid.js
vendored
@@ -38069,6 +38069,10 @@ exports.encodeEntities = function(text){
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//txt = txt.replace(/fa:fa[\w\-]+/g,function(s,t,u){
|
||||||
|
// return 'fa:¢';
|
||||||
|
//});
|
||||||
|
|
||||||
return txt;
|
return txt;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -38085,6 +38089,8 @@ exports.decodeEntities = function(text){
|
|||||||
return ';';
|
return ';';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return txt;
|
return txt;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
|
@@ -212,7 +212,23 @@ graph LR
|
|||||||
id1["This is the (text) in the box"]
|
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
|
## Subgraphs
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@@ -86,9 +86,11 @@ Logger.levels = {
|
|||||||
warn: 3,
|
warn: 3,
|
||||||
error: 4,
|
error: 4,
|
||||||
fatal: 5,
|
fatal: 5,
|
||||||
default:1
|
default:5
|
||||||
};
|
};
|
||||||
|
exports.setLogLevel = function(level){
|
||||||
exports.create = function(type, options) {
|
Logger.levels.default = level;
|
||||||
|
}
|
||||||
|
exports.create = function(options) {
|
||||||
return new Logger(options);
|
return new Logger(options);
|
||||||
};
|
};
|
@@ -45,6 +45,7 @@ module.exports.mermaidAPI = mermaidAPI;
|
|||||||
* @param nodes a css selector or an array of nodes
|
* @param nodes a css selector or an array of nodes
|
||||||
*/
|
*/
|
||||||
var init = function () {
|
var init = function () {
|
||||||
|
var conf= mermaidAPI.getConfig();
|
||||||
log.debug('Starting rendering diagrams');
|
log.debug('Starting rendering diagrams');
|
||||||
var nodes;
|
var nodes;
|
||||||
if(arguments.length >= 2){
|
if(arguments.length >= 2){
|
||||||
@@ -65,7 +66,6 @@ var init = function () {
|
|||||||
callback = arguments[arguments.length-1];
|
callback = arguments[arguments.length-1];
|
||||||
log.debug('Callback function found');
|
log.debug('Callback function found');
|
||||||
}else{
|
}else{
|
||||||
var conf= mermaidAPI.getConfig();
|
|
||||||
if(typeof conf.mermaid !== 'undefined'){
|
if(typeof conf.mermaid !== 'undefined'){
|
||||||
if(typeof conf.mermaid.callback === 'function'){
|
if(typeof conf.mermaid.callback === 'function'){
|
||||||
callback = conf.mermaid.callback;
|
callback = conf.mermaid.callback;
|
||||||
|
@@ -28,7 +28,7 @@ var ganttParser = require('./diagrams/gantt/parser/gantt');
|
|||||||
var ganttDb = require('./diagrams/gantt/ganttDb');
|
var ganttDb = require('./diagrams/gantt/ganttDb');
|
||||||
var d3 = require('./d3');
|
var d3 = require('./d3');
|
||||||
var nextId = 0;
|
var nextId = 0;
|
||||||
var log = require('./logger').create();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ## Configuration
|
* ## Configuration
|
||||||
@@ -42,6 +42,15 @@ var log = require('./logger').create();
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
var config = {
|
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
|
* **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
|
* ## parse
|
||||||
* Function that parses a mermaid diagram definition. If parsing fails the parseError callback is called and an error is
|
* 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;
|
var j;
|
||||||
for(j=0;j<lvl2Keys.length;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'){
|
if(typeof config[lvl1Keys[i]] === 'undefined'){
|
||||||
|
|
||||||
config[lvl1Keys[i]] = {};
|
config[lvl1Keys[i]] = {};
|
||||||
@@ -454,6 +465,7 @@ var setConf = function(cnf){
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
exports.initialize = function(options){
|
exports.initialize = function(options){
|
||||||
|
log.debug('Initializing mermaidAPI');
|
||||||
// Update default config with options supplied at initialization
|
// Update default config with options supplied at initialization
|
||||||
if(typeof options === 'object'){
|
if(typeof options === 'object'){
|
||||||
setConf(options);
|
setConf(options);
|
||||||
|
11
src/utils.js
11
src/utils.js
@@ -21,20 +21,11 @@ var log = require('./logger').create();
|
|||||||
* @returns {string} A graph definition key
|
* @returns {string} A graph definition key
|
||||||
*/
|
*/
|
||||||
module.exports.detectType = function(text,a){
|
module.exports.detectType = function(text,a){
|
||||||
|
text = text.replace(/^\s*%%.*\n/g,'\n');
|
||||||
if(text.match(/^\s*sequenceDiagram/)){
|
if(text.match(/^\s*sequenceDiagram/)){
|
||||||
return "sequenceDiagram";
|
return "sequenceDiagram";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(text.match(/^\s*sequence/)){
|
|
||||||
/* ```mermaid
|
|
||||||
graph TB
|
|
||||||
a-->b
|
|
||||||
b-->c
|
|
||||||
```
|
|
||||||
*/
|
|
||||||
return "sequence";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(text.match(/^\s*digraph/)) {
|
if(text.match(/^\s*digraph/)) {
|
||||||
//log.debug('Detected dot syntax');
|
//log.debug('Detected dot syntax');
|
||||||
return "dotGraph";
|
return "dotGraph";
|
||||||
|
@@ -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 () {
|
it('should handle a graph defintion', function () {
|
||||||
str = 'graph TB\nbfs1:queue';
|
str = 'graph TB\nbfs1:queue';
|
||||||
|
|
||||||
@@ -40,12 +27,6 @@ describe('when detecting chart type ',function() {
|
|||||||
var type = utils.detectType(str);
|
var type = utils.detectType(str);
|
||||||
expect(type).toBe('graph');
|
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() {
|
describe('when cloning CSS ',function() {
|
||||||
|
31
test/examples/leadingComments.html
Normal file
31
test/examples/leadingComments.html
Normal 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>
|
Reference in New Issue
Block a user