From 7cfbedb929f44721c29945cb96cb238d0c0486da Mon Sep 17 00:00:00 2001 From: mwiegand Date: Sat, 16 May 2026 19:11:56 +0200 Subject: [PATCH] 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 --- l4d2web/l4d2web/static/js/srccfg-grammar.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 l4d2web/l4d2web/static/js/srccfg-grammar.js diff --git a/l4d2web/l4d2web/static/js/srccfg-grammar.js b/l4d2web/l4d2web/static/js/srccfg-grammar.js new file mode 100644 index 0000000..7f8326e --- /dev/null +++ b/l4d2web/l4d2web/static/js/srccfg-grammar.js @@ -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);