From b2142b93e0a0fb37f0a00a46a8474daea2ec8a0f Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Tue, 3 Aug 2021 21:46:02 -0700 Subject: [PATCH] Add katex style to root of notebook Fixes #128490 This is needed to ensure the katex font-face is loaded properly Seems like this is needed to work around a bug: https://bugs.chromium.org/p/chromium/issues/detail?id=336876 --- extensions/markdown-math/notebook/katex.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/extensions/markdown-math/notebook/katex.ts b/extensions/markdown-math/notebook/katex.ts index 0753199edad..c0c8aa7643d 100644 --- a/extensions/markdown-math/notebook/katex.ts +++ b/extensions/markdown-math/notebook/katex.ts @@ -14,11 +14,21 @@ export async function activate(ctx: { throw new Error('Could not load markdownItRenderer'); } + // Add katex styles to be copied to shadow dom const link = document.createElement('link'); link.rel = 'stylesheet'; link.classList.add('markdown-style'); link.href = styleHref; + // Add same katex style to root document. + // This is needed for the font to be loaded correctly inside the shadow dom. + // + // Seems like https://bugs.chromium.org/p/chromium/issues/detail?id=336876 + const linkHead = document.createElement('link'); + linkHead.rel = 'stylesheet'; + linkHead.href = styleHref; + document.head.appendChild(linkHead); + const style = document.createElement('style'); style.textContent = ` .katex-error {