fix(ui): force wasm highlighter for markdown code blocks (#17373)
This commit is contained in:
parent
f5f07310e0
commit
5aaf1ddfb7
1 changed files with 10 additions and 2 deletions
|
|
@ -428,7 +428,11 @@ async function highlightCodeBlocks(html: string): Promise<string> {
|
||||||
const matches = [...html.matchAll(codeBlockRegex)]
|
const matches = [...html.matchAll(codeBlockRegex)]
|
||||||
if (matches.length === 0) return html
|
if (matches.length === 0) return html
|
||||||
|
|
||||||
const highlighter = await getSharedHighlighter({ themes: ["OpenCode"], langs: [] })
|
const highlighter = await getSharedHighlighter({
|
||||||
|
themes: ["OpenCode"],
|
||||||
|
langs: [],
|
||||||
|
preferredHighlighter: "shiki-wasm",
|
||||||
|
})
|
||||||
|
|
||||||
let result = html
|
let result = html
|
||||||
for (const match of matches) {
|
for (const match of matches) {
|
||||||
|
|
@ -479,7 +483,11 @@ export const { use: useMarked, provider: MarkedProvider } = createSimpleContext(
|
||||||
}),
|
}),
|
||||||
markedShiki({
|
markedShiki({
|
||||||
async highlight(code, lang) {
|
async highlight(code, lang) {
|
||||||
const highlighter = await getSharedHighlighter({ themes: ["OpenCode"], langs: [] })
|
const highlighter = await getSharedHighlighter({
|
||||||
|
themes: ["OpenCode"],
|
||||||
|
langs: [],
|
||||||
|
preferredHighlighter: "shiki-wasm",
|
||||||
|
})
|
||||||
if (!(lang in bundledLanguages)) {
|
if (!(lang in bundledLanguages)) {
|
||||||
lang = "text"
|
lang = "text"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue