Skip to content

Commit 51cba07

Browse files
authored
Update shiki (#2583)
1 parent 2c945c6 commit 51cba07

File tree

11 files changed

+4
-53
lines changed

11 files changed

+4
-53
lines changed

bun.lockb

1.13 KB
Binary file not shown.

packages/gitbook/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"remark-rehype": "^11.1.0",
6161
"rison": "^0.1.1",
6262
"server-only": "^0.0.1",
63-
"shiki": "^1.22.0",
63+
"shiki": "^1.23.1",
6464
"tailwind-merge": "^2.2.0",
6565
"tailwind-shades": "^1.1.2",
6666
"unified": "^11.0.4",

packages/gitbook/src/app/(space)/~gitbook/pdf/page.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Metadata } from 'next';
1111
import { notFound } from 'next/navigation';
1212
import * as React from 'react';
1313

14-
import { DocumentView, createHighlightingContext } from '@/components/DocumentView';
14+
import { DocumentView } from '@/components/DocumentView';
1515
import { TrademarkLink } from '@/components/TableOfContents/Trademark';
1616
import { PolymorphicComponentProp } from '@/components/utils/types';
1717
import { getSpaceLanguage } from '@/intl/server';
@@ -227,7 +227,6 @@ async function PDFPageDocument(props: {
227227
const { space, page, refContext } = props;
228228

229229
const document = page.documentId ? await getDocument(space.id, page.documentId) : null;
230-
const shouldHighlightCode = createHighlightingContext();
231230

232231
return (
233232
<PrintPage id={pagePDFContainerId(page)}>
@@ -250,7 +249,6 @@ async function PDFPageDocument(props: {
250249
contentRefContext: refContext,
251250
resolveContentRef: (ref) => resolveContentRef(ref, refContext),
252251
getId: (id) => pagePDFContainerId(page, id),
253-
shouldHighlightCode,
254252
}}
255253
/>
256254
) : null}

packages/gitbook/src/components/DocumentView/CodeBlock/CodeBlock.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import './theme.css';
1515
*/
1616
export async function CodeBlock(props: BlockProps<DocumentBlockCode>) {
1717
const { block, document, style, context } = props;
18-
const withHighlighting = context.shouldHighlightCode(context.content?.spaceId);
19-
const lines = withHighlighting ? await highlight(block) : plainHighlighting(block);
18+
const lines = await highlight(block);
2019

2120
const id = block.key!;
2221

packages/gitbook/src/components/DocumentView/CodeBlock/PlainCodeBlock.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export function PlainCodeBlock(props: { code: string; syntax: string }) {
5050
mode: 'default',
5151
contentRefContext: null,
5252
resolveContentRef: async () => null,
53-
shouldHighlightCode: () => true,
5453
}}
5554
block={block}
5655
ancestorBlocks={[]}

packages/gitbook/src/components/DocumentView/CodeBlock/createHighlightingContext.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export * from './CodeBlock';
22
export * from './PlainCodeBlock';
3-
export * from './createHighlightingContext';

packages/gitbook/src/components/DocumentView/DocumentView.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,6 @@ export interface DocumentContext {
3838
*/
3939
getId?: (id: string) => string;
4040

41-
/**
42-
* Returns true if the given code block should be highlighted.
43-
* This function was added to protect against memory issues when highlighting
44-
* a large number of code blocks.
45-
* Once highlighting can scale up to a large number of code blocks, it can be removed.
46-
*
47-
* https://linear.app/gitbook-x/issue/RND-3588/gitbook-open-code-syntax-highlighting-runs-out-of-memory-after-a
48-
*/
49-
shouldHighlightCode: (spaceId: string | undefined) => boolean;
50-
5141
/**
5242
* True if the blocks should be wrapped in suspense boundary for isolated loading skeletons.
5343
* @default true
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export * from './DocumentView';
2-
export { createHighlightingContext } from './CodeBlock';

packages/gitbook/src/components/PageBody/PageBody.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { PageFooterNavigation } from './PageFooterNavigation';
2121
import { PageHeader } from './PageHeader';
2222
import { PreservePageLayout } from './PreservePageLayout';
2323
import { TrackPageView } from './TrackPageView';
24-
import { DocumentView, DocumentViewSkeleton, createHighlightingContext } from '../DocumentView';
24+
import { DocumentView, DocumentViewSkeleton } from '../DocumentView';
2525
import { PageFeedbackForm } from '../PageFeedback';
2626
import { DateRelative } from '../primitives';
2727

@@ -49,7 +49,6 @@ export function PageBody(props: {
4949
const asFullWidth = document ? hasFullWidthBlock(document) : false;
5050
const language = getSpaceLanguage(customization);
5151
const updatedAt = page.updatedAt ?? page.createdAt;
52-
const shouldHighlightCode = createHighlightingContext();
5352

5453
return (
5554
<>
@@ -100,7 +99,6 @@ export function PageBody(props: {
10099
contentRefContext: context,
101100
resolveContentRef: (ref, options) =>
102101
resolveContentRef(ref, context, options),
103-
shouldHighlightCode,
104102
}}
105103
/>
106104
</React.Suspense>

0 commit comments

Comments
 (0)