mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-21 08:19:43 +02:00
Fix for issue #895
This commit is contained in:
@@ -37,9 +37,9 @@ const sanitize = text => {
|
||||
* @param style
|
||||
* @param classes
|
||||
*/
|
||||
export const addVertex = function (id, text, type, style, classes) {
|
||||
export const addVertex = function (_id, text, type, style, classes) {
|
||||
let txt
|
||||
|
||||
let id = _id
|
||||
if (typeof id === 'undefined') {
|
||||
return
|
||||
}
|
||||
@@ -47,6 +47,8 @@ export const addVertex = function (id, text, type, style, classes) {
|
||||
return
|
||||
}
|
||||
|
||||
if (id[0].match(/\d/)) id = 's' + id
|
||||
|
||||
if (typeof vertices[id] === 'undefined') {
|
||||
vertices[id] = { id: id, styles: [], classes: [] }
|
||||
}
|
||||
@@ -338,7 +340,12 @@ export const defaultStyle = function () {
|
||||
/**
|
||||
* Clears the internal graph db so that a new graph can be parsed.
|
||||
*/
|
||||
export const addSubGraph = function (id, list, title) {
|
||||
export const addSubGraph = function (_id, list, _title) {
|
||||
let id = _id
|
||||
let title = _title
|
||||
if (_id === _title && _title.match(/\s/)) {
|
||||
id = undefined
|
||||
}
|
||||
function uniq (a) {
|
||||
const prims = { 'boolean': {}, 'number': {}, 'string': {} }
|
||||
const objs = []
|
||||
@@ -357,7 +364,7 @@ export const addSubGraph = function (id, list, title) {
|
||||
nodeList = uniq(nodeList.concat.apply(nodeList, list))
|
||||
|
||||
id = id || ('subGraph' + subCount)
|
||||
id = 's' + id
|
||||
if (id[0].match(/\d/)) id = 's' + id
|
||||
title = title || ''
|
||||
title = sanitize(title)
|
||||
subCount = subCount + 1
|
||||
|
Reference in New Issue
Block a user