fix: async highlight and escape html in docs (#2512)
This commit is contained in:
parent
4089ee8786
commit
6e5180bd1c
|
@ -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)
|
||||||
})();
|
})();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue