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
1 changed files with 4 additions and 12 deletions

View File

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