Merge pull request #608 from SISheogorath/fix/mermaid

Use mermaidAPI in mermaid scope
This commit is contained in:
Sheogorath 2017-10-30 07:24:57 +01:00 committed by GitHub
commit b3c66d4a10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -373,18 +373,10 @@ export function finishView (view) {
var $value = $(value)
const $ele = $(value).closest('pre')
let mermaidError = null
window.mermaid.parseError = (err, hash) => {
mermaidError = err
}
if (window.mermaidAPI.parse($value.text())) {
$ele.addClass('mermaid')
$ele.html($value.text())
window.mermaid.init(undefined, $ele)
} else {
throw new Error(mermaidError)
}
window.mermaid.mermaidAPI.parse($value.text())
$ele.addClass('mermaid')
$ele.html($value.text())
window.mermaid.init(undefined, $ele)
} catch (err) {
$value.unwrap()
$value.parent().append('<div class="alert alert-warning">' + err + '</div>')