From 6e5180bd1c89713d08c707bfede58ee0131161ed Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Thu, 25 Nov 2021 12:43:16 -0800 Subject: [PATCH] fix: async highlight and escape html in docs (#2512) --- docs/index.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/index.html b/docs/index.html index 9c381da99..eef5f1280 100644 --- a/docs/index.html +++ b/docs/index.html @@ -55,6 +55,10 @@ }) } + function escapeHTML(html) { + return html.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"').replaceAll('\'', ''') + } + window.$docsify = { search: 'auto', name: 'mermaid', @@ -73,7 +77,7 @@ currentCodeExample++; colorize.push(currentCodeExample); resultingHTML += ( - '
' + code + '
' + '
' + escapeHTML(code) + '
' ) } @@ -100,10 +104,11 @@ }) hook.afterEach(function (html, next) { + next(html); (async() => { while (!window.hasOwnProperty("monaco")) await new Promise(resolve => setTimeout(resolve, 1000)); - colorizeEverything(html).then(newHTML => next(newHTML)) + colorizeEverything(html).then(newHTML => document.querySelector('article.markdown-section').innerHTML = newHTML) })(); }) }