mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-14 21:09:50 +02:00
Emit parseError
This commit is contained in:
@@ -10,7 +10,9 @@
|
||||
* The core of this api is the **render** function that given a graph definitionas text renders the graph/diagram and
|
||||
* returns a svg element for the graph. It is is then up to the user of the API to make use of the svg, either insert it
|
||||
* somewhere in the page or something completely different.
|
||||
*/
|
||||
*/
|
||||
import EventEmitter from 'events'
|
||||
|
||||
var Logger = require('./logger')
|
||||
var log = Logger.Log
|
||||
|
||||
@@ -36,6 +38,8 @@ var gitGraphRenderer = require('./diagrams/gitGraph/gitGraphRenderer')
|
||||
var gitGraphAst = require('./diagrams/gitGraph/gitGraphAst')
|
||||
var d3 = require('./d3')
|
||||
|
||||
module.exports.eventEmitter = new EventEmitter()
|
||||
|
||||
/**
|
||||
* ## Configuration
|
||||
* These are the default options which can be overridden with the initialization call as in the example below:
|
||||
@@ -283,6 +287,10 @@ var parse = function (text) {
|
||||
break
|
||||
}
|
||||
|
||||
parser.parser.yy.parseError = (err, hash) => {
|
||||
module.exports.eventEmitter.emit('parseError', err, hash)
|
||||
}
|
||||
|
||||
try {
|
||||
parser.parse(text)
|
||||
return true
|
||||
@@ -543,11 +551,13 @@ module.exports.parseError = function (err, hash) {
|
||||
log.debug(err)
|
||||
}
|
||||
}
|
||||
|
||||
global.mermaidAPI = {
|
||||
render: module.exports.render,
|
||||
parse: module.exports.parse,
|
||||
initialize: module.exports.initialize,
|
||||
detectType: utils.detectType,
|
||||
parseError: module.exports.parseError,
|
||||
getConfig: module.exports.getConfig
|
||||
getConfig: module.exports.getConfig,
|
||||
eventEmitter: module.exports.eventEmitter
|
||||
}
|
||||
|
Reference in New Issue
Block a user