website
git clone https://git.pyrossh.dev/website
木 Personal website of pyrossh. Built with astrojs, shiki, vite.
src/_helpers/prism-plum.js
| 9273acf | 1 | import Prism from "prismjs"; |
| 9273acf | 2 | |
| 9273acf | 3 | // Hand-written Prism grammar for the plum language (github.com/pyrossh/plum), |
| 9273acf | 4 | // kept in sync with its tree-sitter grammar (tooling/tree-sitter-plum/grammar.js) |
| 9273acf | 5 | // and highlight query (tooling/tree-sitter-plum/queries/plum/highlights.scm) — |
| 9273acf | 6 | // there's no off-the-shelf Prism component for it, and this build only ever |
| 9273acf | 7 | // highlights at build time via Prism (see highlightCode.js), so a tree-sitter |
| 9273acf | 8 | // runtime isn't pulled in just for this one language. |
| 9273acf | 9 | Prism.languages.plum = { |
| 9273acf | 10 | comment: /#.*/, |
| 9273acf | 11 | string: { |
| 9273acf | 12 | pattern: /"(?:\\.|\{[^{}]*\}|[^"\\{])*"/, |
| 9273acf | 13 | greedy: true, |
| 9273acf | 14 | inside: { |
| 9273acf | 15 | interpolation: { |
| 9273acf | 16 | pattern: /\{[^{}]*\}/, |
| 9273acf | 17 | inside: { |
| 9273acf | 18 | punctuation: /^\{|\}$/, |
| 9273acf | 19 | rest: null, |
| 9273acf | 20 | }, |
| 9273acf | 21 | }, |
| 9273acf | 22 | "escape-sequence": { |
| 9273acf | 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\{[^}]+\}|.|$)/, |
| 9273acf | 24 | alias: "constant", |
| 9273acf | 25 | }, |
| 9273acf | 26 | }, |
| 9273acf | 27 | }, |
| 9273acf | 28 | "raw-string": { |
| 9273acf | 29 | pattern: /`[^`]*`/, |
| 9273acf | 30 | greedy: true, |
| 9273acf | 31 | alias: "string", |
| 9273acf | 32 | }, |
| 9273acf | 33 | keyword: |
| 9273acf | 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/, |
| 9273acf | 35 | builtin: /\bself\b|\B_\b/, |
| 9273acf | 36 | function: /\b[a-z][a-zA-Z0-9]*(?:_[a-zA-Z0-9]+)*(?=\()/, |
| 9273acf | 37 | constant: /\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*\b/, |
| 9273acf | 38 | "class-name": /\b[A-Z][a-zA-Z0-9]+\b/, |
| 9273acf | 39 | number: |
| 9273acf | 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/, |
| 9273acf | 41 | operator: /\.\.\.|<<|>>|<=|>=|==|!=|<>|&&|\|\||:=|->|=>|[-+*/%^&|<>=!]/, |
| 9273acf | 42 | punctuation: /[(){}\[\].,:|]/, |
| 9273acf | 43 | }; |
| 9273acf | 44 | |
| 9273acf | 45 | Prism.languages.plum.string.inside.interpolation.inside.rest = Prism.languages.plum; |