Compare commits

...

2 Commits

Author SHA1 Message Date
Claire Chabas ad4f27cbed add changeset 2025-07-18 12:16:45 +02:00
Claire Chabas 6a3e1cf691 Fix code block crashing published page in Safari 2025-07-18 12:08:36 +02:00
2 changed files with 14 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Fix code block with PowerShell crashing page in Safari
@@ -34,6 +34,9 @@ export type RenderedInline = {
body: React.ReactNode;
};
const isSafari =
typeof navigator !== 'undefined' && /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
const theme = createCssVariablesTheme();
const { getSingletonHighlighter } = createSingletonShorthands(
@@ -65,8 +68,12 @@ export async function highlight(
inlines: RenderedInline[]
): Promise<HighlightLine[]> {
const langName = getBlockLang(block);
if (!langName) {
// Language not found, fallback to plain highlighting
if (!langName || (isSafari && langName === 'powershell')) {
// Fallback to plain highlighting if
// - language is not found
// - language is `powershell` and browser is Safari:
// PowerShell commands can trigger complex regex that Safari
// JS engine doesn't support, causing the highlighter to crash.
return plainHighlight(block, inlines);
}