feat(editor): add Prism grammar for Source-engine .cfg syntax
Five token classes (comment, string, keyword, number, identifier) plus operators. Purely visual highlighting; no semantic validation of cvar names or values. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4a1b6d5fac
commit
7cfbedb929
1 changed files with 17 additions and 0 deletions
17
l4d2web/l4d2web/static/js/srccfg-grammar.js
Normal file
17
l4d2web/l4d2web/static/js/srccfg-grammar.js
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
// Prism grammar for Source-engine config files (server.cfg-style).
|
||||||
|
// Tokens: comment, string, number, keyword, identifier. Purely visual —
|
||||||
|
// no semantic validation of cvars or values.
|
||||||
|
(function (Prism) {
|
||||||
|
if (!Prism) return;
|
||||||
|
Prism.languages.srccfg = {
|
||||||
|
comment: /\/\/.*/,
|
||||||
|
string: {
|
||||||
|
pattern: /"(?:\\.|[^"\\])*"/,
|
||||||
|
greedy: true,
|
||||||
|
},
|
||||||
|
keyword: /\b(?:exec|alias|bind|unbind|toggle)\b/,
|
||||||
|
number: /\b-?\d+(?:\.\d+)?\b/,
|
||||||
|
identifier: /\b[a-zA-Z_][a-zA-Z0-9_]*\b/,
|
||||||
|
operator: /[+\-;]/,
|
||||||
|
};
|
||||||
|
})(typeof window !== "undefined" ? window.Prism : undefined);
|
||||||
Loading…
Reference in a new issue