#918 Fix for issue with nodes starting with a number in a subgraph
28
e2e/platform/vertices.html
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<title>Mermaid Quick Test Page</title>
|
||||||
|
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'trebuchet ms', verdana, arial;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="mermaid">
|
||||||
|
graph TD
|
||||||
|
A --> B --> C
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="./mermaid.js"></script>
|
||||||
|
<script>
|
||||||
|
function showFullFirstSquad(elemName) {
|
||||||
|
console.log('show ' + elemName);
|
||||||
|
}
|
||||||
|
mermaid.initialize({ startOnLoad: true, securityLevel: 'loose', logLevel: 1 });
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
After Width: | Height: | Size: 104 KiB |
After Width: | Height: | Size: 88 KiB |
After Width: | Height: | Size: 146 KiB |
After Width: | Height: | Size: 77 KiB |
After Width: | Height: | Size: 63 KiB |
After Width: | Height: | Size: 95 KiB |
After Width: | Height: | Size: 105 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 63 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 135 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 137 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 8.2 KiB |
After Width: | Height: | Size: 18 KiB |
@@ -149,6 +149,12 @@ describe('Flowcart', () => {
|
|||||||
{})
|
{})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should render labels with numbers at the start', async () => {
|
||||||
|
await imgSnapshotTest(page, `
|
||||||
|
graph TB;subgraph "number as labels";1;end;
|
||||||
|
`,
|
||||||
|
{})
|
||||||
|
})
|
||||||
it('should render subgraphs', async () => {
|
it('should render subgraphs', async () => {
|
||||||
await imgSnapshotTest(page, `
|
await imgSnapshotTest(page, `
|
||||||
graph TB
|
graph TB
|
||||||
|
@@ -38,6 +38,7 @@ const sanitize = text => {
|
|||||||
* @param classes
|
* @param classes
|
||||||
*/
|
*/
|
||||||
export const addVertex = function (_id, text, type, style, classes) {
|
export const addVertex = function (_id, text, type, style, classes) {
|
||||||
|
console.log('called with',_id);
|
||||||
let txt
|
let txt
|
||||||
let id = _id
|
let id = _id
|
||||||
if (typeof id === 'undefined') {
|
if (typeof id === 'undefined') {
|
||||||
@@ -373,6 +374,9 @@ export const addSubGraph = function (_id, list, _title) {
|
|||||||
let nodeList = []
|
let nodeList = []
|
||||||
|
|
||||||
nodeList = uniq(nodeList.concat.apply(nodeList, list))
|
nodeList = uniq(nodeList.concat.apply(nodeList, list))
|
||||||
|
for(let i=0;i<nodeList.length;i++){
|
||||||
|
if(nodeList[i][0].match(/\d/)) nodeList[i] = 's' + nodeList[i];
|
||||||
|
}
|
||||||
|
|
||||||
id = id || ('subGraph' + subCount)
|
id = id || ('subGraph' + subCount)
|
||||||
if (id[0].match(/\d/)) id = 's' + id
|
if (id[0].match(/\d/)) id = 's' + id
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
"BT" return 'DIR';
|
"BT" return 'DIR';
|
||||||
"TD" return 'DIR';
|
"TD" return 'DIR';
|
||||||
"BR" return 'DIR';
|
"BR" return 'DIR';
|
||||||
[0-9]+ return 'NUM';
|
[0-9]+ { console.log('got NUM'); return 'NUM';}
|
||||||
\# return 'BRKT';
|
\# return 'BRKT';
|
||||||
":::" return 'STYLE_SEPARATOR';
|
":::" return 'STYLE_SEPARATOR';
|
||||||
":" return 'COLON';
|
":" return 'COLON';
|
||||||
@@ -241,7 +241,7 @@ spaceList
|
|||||||
|
|
||||||
statement
|
statement
|
||||||
: verticeStatement separator
|
: verticeStatement separator
|
||||||
{$$=$1}
|
{ $$=$1}
|
||||||
| styleStatement separator
|
| styleStatement separator
|
||||||
{$$=[];}
|
{$$=[];}
|
||||||
| linkStyleStatement separator
|
| linkStyleStatement separator
|
||||||
@@ -280,11 +280,11 @@ separator: NEWLINE | SEMI | EOF ;
|
|||||||
// ;
|
// ;
|
||||||
|
|
||||||
verticeStatement: verticeStatement link node { yy.addLink($1[0],$3[0],$2); $$ = $3.concat($1) }
|
verticeStatement: verticeStatement link node { yy.addLink($1[0],$3[0],$2); $$ = $3.concat($1) }
|
||||||
|node { $$ = $1 }
|
|node { console.log('A node', $1);$$ = $1 }
|
||||||
;
|
;
|
||||||
|
|
||||||
node: vertex
|
node: vertex
|
||||||
{$$ = [$1];}
|
{ console.log('A vertex', $1);$$ = [$1];}
|
||||||
| vertex STYLE_SEPARATOR idString
|
| vertex STYLE_SEPARATOR idString
|
||||||
{$$ = [$1];yy.setClass($1,$3)}
|
{$$ = [$1];yy.setClass($1,$3)}
|
||||||
;
|
;
|
||||||
|
@@ -1414,6 +1414,27 @@ describe('when parsing ', function () {
|
|||||||
expect(edges.length).toBe(0)
|
expect(edges.length).toBe(0)
|
||||||
expect(vert['id1'].styles.length).toBe(0)
|
expect(vert['id1'].styles.length).toBe(0)
|
||||||
})
|
})
|
||||||
|
it('should handle a single node with a single digit', function () {
|
||||||
|
// Silly but syntactically correct
|
||||||
|
const res = flow.parser.parse('graph TD;1;')
|
||||||
|
|
||||||
|
const vert = flow.parser.yy.getVertices()
|
||||||
|
const edges = flow.parser.yy.getEdges()
|
||||||
|
|
||||||
|
expect(edges.length).toBe(0)
|
||||||
|
expect(vert['s1'].text).toBe('1')
|
||||||
|
})
|
||||||
|
it('should handle a single node with a single digit in a subgraph', function () {
|
||||||
|
// Silly but syntactically correct
|
||||||
|
|
||||||
|
const res = flow.parser.parse('graph TD;subgraph "hello";1;end;')
|
||||||
|
|
||||||
|
const vert = flow.parser.yy.getVertices()
|
||||||
|
const edges = flow.parser.yy.getEdges()
|
||||||
|
|
||||||
|
expect(edges.length).toBe(0)
|
||||||
|
expect(vert['s1'].text).toBe('1')
|
||||||
|
})
|
||||||
it('should handle a single node with alphanumerics starting on a num', function () {
|
it('should handle a single node with alphanumerics starting on a num', function () {
|
||||||
// Silly but syntactically correct
|
// Silly but syntactically correct
|
||||||
const res = flow.parser.parse('graph TD;1id;')
|
const res = flow.parser.parse('graph TD;1id;')
|
||||||
|