vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.33k stars 1.83k forks source link

希望支持 LaTeX3 语法高亮 #3781

Closed xkwxdyy closed 2 weeks ago

xkwxdyy commented 2 weeks ago

Is your feature request related to a problem? Please describe.

希望官方能支持 LaTeX3 语法(expl3)高亮。

我尝试了 shiki 官网的方法 按照它的配置在.vitepress/config.mts 中加入了

import { getHighlighter } from 'shiki'

const latex3 = JSON.parse(fs.readFileSync('../../LaTeX-Expl3.tmLanguage.json', 'utf8'))

const highlighter = await getHighlighter({
  langs: [latex3],
  themes: ['vitesse-light']
})

const html = highlighter.codeToHtml(code, {
  lang: 'my-lang',
  theme: 'vitesse-light'
})

但是 VScode 提示我

找不到名称“fs”。
找不到名称“code”。

我没有什么 ts 代码基础,不知道怎么改。但是 LaTeX3 用得也很普遍,所以希望官方能够支持,这样就不需要我额外配置了。

Describe the solution you'd like

调用 VScode 的 LaTeX-Workshop 里的高亮就行

Describe alternatives you've considered

No response

Additional context

No response

Validations

brc-dd commented 2 weeks ago

Refer #3779