website
git clone https://git.pyrossh.dev/website
木 Personal website of pyrossh. Built with astrojs, shiki, vite.
9273acf
— pyrossh
2026-09-04T21:17:39+05:30
Add Prism syntax highlighting for the plum language
- src/_helpers/highlightCode.js +1 -1
- src/_helpers/prism-plum.js +45 -0
src/_helpers/highlightCode.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Prism from "prismjs";
|
|
2
2
|
import loadPrismLanguage from "prismjs/components/index.js";
|
|
3
|
+
import "./prism-plum.js";
|
|
3
4
|
|
|
4
5
|
// Avoid "Language does not exist" console noise for extensions we don't
|
|
5
6
|
// have a mapping for — those just fall back to plain, unhighlighted text.
|
|
@@ -24,7 +25,6 @@ const EXT_TO_LANG = {
|
|
|
24
25
|
ts: "typescript",
|
|
25
26
|
mi: null,
|
|
26
27
|
nu: null,
|
|
27
|
-
plum: null,
|
|
28
28
|
txt: null,
|
|
29
29
|
typ: null,
|
|
30
30
|
};
|
src/_helpers/prism-plum.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import Prism from "prismjs";
|
|
2
|
+
|
|
3
|
+
// Hand-written Prism grammar for the plum language (github.com/pyrossh/plum),
|
|
4
|
+
// kept in sync with its tree-sitter grammar (tooling/tree-sitter-plum/grammar.js)
|
|
5
|
+
// and highlight query (tooling/tree-sitter-plum/queries/plum/highlights.scm) —
|
|
6
|
+
// there's no off-the-shelf Prism component for it, and this build only ever
|
|
7
|
+
// highlights at build time via Prism (see highlightCode.js), so a tree-sitter
|
|
8
|
+
// runtime isn't pulled in just for this one language.
|
|
9
|
+
Prism.languages.plum = {
|
|
10
|
+
comment: /#.*/,
|
|
11
|
+
string: {
|
|
12
|
+
pattern: /"(?:\\.|\{[^{}]*\}|[^"\\{])*"/,
|
|
13
|
+
greedy: true,
|
|
14
|
+
inside: {
|
|
15
|
+
interpolation: {
|
|
16
|
+
pattern: /\{[^{}]*\}/,
|
|
17
|
+
inside: {
|
|
18
|
+
punctuation: /^\{|\}$/,
|
|
19
|
+
rest: null,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
"escape-sequence": {
|
|
23
|
+
pattern: /\\(?:u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|x[0-9a-fA-F]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|N\{[^}]+\}|.|$)/,
|
|
24
|
+
alias: "constant",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
"raw-string": {
|
|
29
|
+
pattern: /`[^`]*`/,
|
|
30
|
+
greedy: true,
|
|
31
|
+
alias: "string",
|
|
32
|
+
},
|
|
33
|
+
keyword:
|
|
34
|
+
/\b(?:module|import|type|enum|trait|extern|fun|test|for|while|range|if|else if|else|when|match|break|continue|return|assert|todo)\b/,
|
|
35
|
+
builtin: /\bself\b|\B_\b/,
|
|
36
|
+
function: /\b[a-z][a-zA-Z0-9]*(?:_[a-zA-Z0-9]+)*(?=\()/,
|
|
37
|
+
constant: /\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*\b/,
|
|
38
|
+
"class-name": /\b[A-Z][a-zA-Z0-9]+\b/,
|
|
39
|
+
number:
|
|
40
|
+
/\b(?:0[xX][0-9a-fA-F](?:_?[0-9a-fA-F])*|0[bB][01](?:_?[01])*|[0-9][0-9_]*\.[0-9][0-9_]*(?:[eE][+-]?[0-9_]+)?[fF]?|[0-9][0-9_]*[eE][+-]?[0-9_]+[fF]?|[0-9][0-9_]*[fF]|[0-9][0-9_]*)\b/,
|
|
41
|
+
operator: /\.\.\.|<<|>>|<=|>=|==|!=|<>|&&|\|\||:=|->|=>|[-+*/%^&|<>=!]/,
|
|
42
|
+
punctuation: /[(){}\[\].,:|]/,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
Prism.languages.plum.string.inside.interpolation.inside.rest = Prism.languages.plum;
|