mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-12-09 22:14:10 +01:00
fix: async highlight and escape html in docs (#2512)
This commit is contained in:
@@ -55,6 +55,10 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function escapeHTML(html) {
|
||||||
|
return html.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"').replaceAll('\'', ''')
|
||||||
|
}
|
||||||
|
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
search: 'auto',
|
search: 'auto',
|
||||||
name: 'mermaid',
|
name: 'mermaid',
|
||||||
@@ -73,7 +77,7 @@
|
|||||||
currentCodeExample++;
|
currentCodeExample++;
|
||||||
colorize.push(currentCodeExample);
|
colorize.push(currentCodeExample);
|
||||||
resultingHTML += (
|
resultingHTML += (
|
||||||
'<pre id="code' + currentCodeExample + '">' + code + '</pre>'
|
'<pre id="code' + currentCodeExample + '">' + escapeHTML(code) + '</pre>'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,10 +104,11 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
hook.afterEach(function (html, next) {
|
hook.afterEach(function (html, next) {
|
||||||
|
next(html);
|
||||||
(async() => {
|
(async() => {
|
||||||
while (!window.hasOwnProperty("monaco"))
|
while (!window.hasOwnProperty("monaco"))
|
||||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
colorizeEverything(html).then(newHTML => next(newHTML))
|
colorizeEverything(html).then(newHTML => document.querySelector('article.markdown-section').innerHTML = newHTML)
|
||||||
})();
|
})();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user