website
git clone https://git.pyrossh.dev/website
木 Personal website of pyrossh. Built with astrojs, shiki, vite.
src/_helpers/prism-plum.js
import Prism from "prismjs";
// Hand-written Prism grammar for the plum language (github.com/pyrossh/plum),
// kept in sync with its tree-sitter grammar (tooling/tree-sitter-plum/grammar.js)
// and highlight query (tooling/tree-sitter-plum/queries/plum/highlights.scm) —
// there's no off-the-shelf Prism component for it, and this build only ever
// highlights at build time via Prism (see highlightCode.js), so a tree-sitter
// runtime isn't pulled in just for this one language.
Prism.languages.plum = {
comment: /#.*/,
string: {
pattern: /"(?:\\.|\{[^{}]*\}|[^"\\{])*"/,
greedy: true,
inside: {
interpolation: {
pattern: /\{[^{}]*\}/,
inside: {
punctuation: /^\{|\}$/,
rest: null,
},
},
"escape-sequence": {
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\{[^}]+\}|.|$)/,
alias: "constant",
},
},
},
"raw-string": {
pattern: /`[^`]*`/,
greedy: true,
alias: "string",
},
keyword:
/\b(?:module|import|type|enum|trait|extern|fun|test|for|while|range|if|else if|else|when|match|break|continue|return|assert|todo)\b/,
builtin: /\bself\b|\B_\b/,
function: /\b[a-z][a-zA-Z0-9]*(?:_[a-zA-Z0-9]+)*(?=\()/,
constant: /\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*\b/,
"class-name": /\b[A-Z][a-zA-Z0-9]+\b/,
number:
/\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/,
operator: /\.\.\.|<<|>>|<=|>=|==|!=|<>|&&|\|\||:=|->|=>|[-+*/%^&|<>=!]/,
punctuation: /[(){}\[\].,:|]/,
};
Prism.languages.plum.string.inside.interpolation.inside.rest = Prism.languages.plum;