1
1
import { readFileSync } from "fs" ;
2
2
import { join } from "path" ;
3
3
import { defineConfig } from "vitepress" ;
4
+ import { bundledLanguages } from "shiki" ;
5
+
6
+ // Modify bundledLanguages so it no longer contains the bundled OCaml grammar. This is needed because vitepress config
7
+ // doesn't allow you to override bundled grammars, see
8
+ // https://github.com/vuejs/vitepress/blob/78c4d3dda085f31912578237dfbe7b1c62f48859/src/node/markdown/plugins/highlight.ts#L65
9
+ delete bundledLanguages [ 'ocaml' ] ;
4
10
5
11
const toggleSyntaxScript = readFileSync ( join ( __dirname , './toggleSyntax.js' ) , 'utf8' ) ;
6
12
@@ -9,16 +15,21 @@ const reasonGrammar = JSON.parse(
9
15
readFileSync ( join ( __dirname , "./reasonml.tmLanguage.json" ) , "utf8" )
10
16
) ;
11
17
12
- // https://github.com/ocamllabs/vscode-ocaml-platform/blob/master/syntaxes/dune.json
18
+ // From https://github.com/ocamllabs/vscode-ocaml-platform/blob/master/syntaxes/dune.json
13
19
const duneGrammar = JSON . parse (
14
20
readFileSync ( join ( __dirname , "./dune.tmLanguage.json" ) , "utf8" )
15
21
) ;
16
22
17
- // https://github.com/ocamllabs/vscode-ocaml-platform/blob/master/syntaxes/opam.json
23
+ // From https://github.com/ocamllabs/vscode-ocaml-platform/blob/master/syntaxes/opam.json
18
24
const opamGrammar = JSON . parse (
19
25
readFileSync ( join ( __dirname , "./opam.tmLanguage.json" ) , "utf8" )
20
26
) ;
21
27
28
+ // From https://github.com/ocamllabs/vscode-ocaml-platform/blob/master/syntaxes/ocaml.json
29
+ const ocamlGrammar = JSON . parse (
30
+ readFileSync ( join ( __dirname , "./ocaml.tmLanguage.json" ) , "utf8" )
31
+ ) ;
32
+
22
33
const base = process . env . BASE || "unstable" ;
23
34
24
35
// https://vitepress.dev/reference/site-config
@@ -38,7 +49,7 @@ export default defineConfig({
38
49
hostname : `https://melange.re/${ base } /` ,
39
50
} ,
40
51
markdown : {
41
- languages : [ reasonGrammar , duneGrammar , opamGrammar ] ,
52
+ languages : [ duneGrammar , ocamlGrammar , opamGrammar , reasonGrammar ] ,
42
53
} ,
43
54
themeConfig : {
44
55
outline : { level : [ 2 , 3 ] } ,
0 commit comments