File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
packages/gitbook/src/components/DocumentView/CodeBlock Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " gitbook " : patch
3+ ---
4+
5+ Remove highlighting in Safari for PowerShell and C++ to avoid page crash until next version with bug fix is released
Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ export type RenderedInline = {
3434 body : React . ReactNode ;
3535} ;
3636
37+ const isSafari =
38+ typeof navigator !== 'undefined' && / ^ ( (? ! c h r o m e | a n d r o i d ) .) * s a f a r i / i. test ( navigator . userAgent ) ;
3739const theme = createCssVariablesTheme ( ) ;
3840
3941const { getSingletonHighlighter } = createSingletonShorthands (
@@ -65,8 +67,13 @@ export async function highlight(
6567 inlines : RenderedInline [ ]
6668) : Promise < HighlightLine [ ] > {
6769 const langName = getBlockLang ( block ) ;
68- if ( ! langName ) {
69- // Language not found, fallback to plain highlighting
70+
71+ if ( ! langName || ( isSafari && [ 'powershell' , 'cpp' ] . includes ( langName ) ) ) {
72+ // Fallback to plain highlighting if
73+ // - language is not found
74+ // - TEMP : language is PowerShell or C++ and browser is Safari:
75+ // RegExp#[Symbol.search] throws TypeError when `lastIndex` isn’t writable
76+ // Fixed in upcoming Safari 18.6, remove when it'll be released - RND-7772
7077 return plainHighlight ( block , inlines ) ;
7178 }
7279
You can’t perform that action at this time.
0 commit comments