fix: support go code block highlighting

This commit is contained in:
lucaronin
2026-05-20 19:30:32 +02:00
parent 0a36915903
commit 5f87debecb
4 changed files with 120 additions and 2 deletions

View File

@@ -123,6 +123,13 @@
"postcss": "8.5.10", "postcss": "8.5.10",
"protobufjs": "7.5.6", "protobufjs": "7.5.6",
"rollup": "4.59.0" "rollup": "4.59.0"
},
"patchedDependencies": {
"@blocknote/core@0.46.2": "patches/@blocknote__core@0.46.2.patch",
"@blocknote/react@0.46.2": "patches/@blocknote__react@0.46.2.patch",
"@tiptap/extension-link@3.19.0": "patches/@tiptap__extension-link@3.19.0.patch",
"prosemirror-tables@1.8.5": "patches/prosemirror-tables@1.8.5.patch",
"@blocknote/code-block@0.46.2": "patches/@blocknote__code-block@0.46.2.patch"
} }
} }
} }

File diff suppressed because one or more lines are too long

7
pnpm-lock.yaml generated
View File

@@ -18,6 +18,9 @@ overrides:
rollup: 4.59.0 rollup: 4.59.0
patchedDependencies: patchedDependencies:
'@blocknote/code-block@0.46.2':
hash: c006cad64c22a2efc10299d85bf72407150fd29a1f16d497b8db0faa071535f8
path: patches/@blocknote__code-block@0.46.2.patch
'@blocknote/core@0.46.2': '@blocknote/core@0.46.2':
hash: 9a05ab63f78eff8887ea009f15116e0e7e70de00eaba31093f3f9584da364df2 hash: 9a05ab63f78eff8887ea009f15116e0e7e70de00eaba31093f3f9584da364df2
path: patches/@blocknote__core@0.46.2.patch path: patches/@blocknote__core@0.46.2.patch
@@ -40,7 +43,7 @@ importers:
version: 0.78.0(zod@4.3.6) version: 0.78.0(zod@4.3.6)
'@blocknote/code-block': '@blocknote/code-block':
specifier: ^0.46.2 specifier: ^0.46.2
version: 0.46.2(@blocknote/core@0.46.2(patch_hash=9a05ab63f78eff8887ea009f15116e0e7e70de00eaba31093f3f9584da364df2)(@types/hast@3.0.4)(highlight.js@11.11.1)(lowlight@3.3.0)) version: 0.46.2(patch_hash=c006cad64c22a2efc10299d85bf72407150fd29a1f16d497b8db0faa071535f8)(@blocknote/core@0.46.2(patch_hash=9a05ab63f78eff8887ea009f15116e0e7e70de00eaba31093f3f9584da364df2)(@types/hast@3.0.4)(highlight.js@11.11.1)(lowlight@3.3.0))
'@blocknote/core': '@blocknote/core':
specifier: ^0.46.2 specifier: ^0.46.2
version: 0.46.2(patch_hash=9a05ab63f78eff8887ea009f15116e0e7e70de00eaba31093f3f9584da364df2)(@types/hast@3.0.4)(highlight.js@11.11.1)(lowlight@3.3.0) version: 0.46.2(patch_hash=9a05ab63f78eff8887ea009f15116e0e7e70de00eaba31093f3f9584da364df2)(@types/hast@3.0.4)(highlight.js@11.11.1)(lowlight@3.3.0)
@@ -6211,7 +6214,7 @@ snapshots:
'@bcoe/v8-coverage@1.0.2': {} '@bcoe/v8-coverage@1.0.2': {}
'@blocknote/code-block@0.46.2(@blocknote/core@0.46.2(patch_hash=9a05ab63f78eff8887ea009f15116e0e7e70de00eaba31093f3f9584da364df2)(@types/hast@3.0.4)(highlight.js@11.11.1)(lowlight@3.3.0))': '@blocknote/code-block@0.46.2(patch_hash=c006cad64c22a2efc10299d85bf72407150fd29a1f16d497b8db0faa071535f8)(@blocknote/core@0.46.2(patch_hash=9a05ab63f78eff8887ea009f15116e0e7e70de00eaba31093f3f9584da364df2)(@types/hast@3.0.4)(highlight.js@11.11.1)(lowlight@3.3.0))':
dependencies: dependencies:
'@blocknote/core': 0.46.2(patch_hash=9a05ab63f78eff8887ea009f15116e0e7e70de00eaba31093f3f9584da364df2)(@types/hast@3.0.4)(highlight.js@11.11.1)(lowlight@3.3.0) '@blocknote/core': 0.46.2(patch_hash=9a05ab63f78eff8887ea009f15116e0e7e70de00eaba31093f3f9584da364df2)(@types/hast@3.0.4)(highlight.js@11.11.1)(lowlight@3.3.0)
'@shikijs/core': 3.23.0 '@shikijs/core': 3.23.0

View File

@@ -70,6 +70,28 @@ describe('editor schema code block highlighting', () => {
expect(highlighter?.getLoadedThemes()[0]).toBe('github-dark') expect(highlighter?.getLoadedThemes()[0]).toBe('github-dark')
}) })
it('registers Go as a selectable Shiki code block language', async () => {
vi.resetModules()
const { createTolariaCodeBlockOptions } = await import('./codeBlockOptions')
const options = createTolariaCodeBlockOptions()
expect(options.supportedLanguages?.go).toMatchObject({
name: 'Go',
aliases: ['go', 'golang'],
})
})
it('loads the Go Shiki grammar for Go code blocks', async () => {
vi.resetModules()
const { createTolariaCodeBlockOptions } = await import('./codeBlockOptions')
const highlighter = await createTolariaCodeBlockOptions().createHighlighter?.()
await expect(highlighter?.loadLanguage('go')).resolves.toBeUndefined()
expect(highlighter?.getLoadedLanguages()).toContain('go')
})
it('omits the Shiki highlighter when WebKit lacks precompiled regex flags', async () => { it('omits the Shiki highlighter when WebKit lacks precompiled regex flags', async () => {
installLegacyWebKitRegExp() installLegacyWebKitRegExp()
vi.resetModules() vi.resetModules()