From a98b5ea6fe8e8cc98a55e0fd793e6e8660ea31c1 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Thu, 30 Dec 2021 19:47:21 +0100 Subject: chore: add prismjs for syntax highlighting --- public/prism/prism-firestore-security-rules.js | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 public/prism/prism-firestore-security-rules.js (limited to 'public/prism/prism-firestore-security-rules.js') diff --git a/public/prism/prism-firestore-security-rules.js b/public/prism/prism-firestore-security-rules.js new file mode 100644 index 0000000..79c9e3b --- /dev/null +++ b/public/prism/prism-firestore-security-rules.js @@ -0,0 +1,36 @@ +Prism.languages['firestore-security-rules'] = Prism.languages.extend('clike', { + comment: /\/\/.*/, + keyword: /\b(?:allow|function|if|match|null|return|rules_version|service)\b/, + operator: /&&|\|\||[<>!=]=?|[-+*/%]|\b(?:in|is)\b/, +}); + +delete Prism.languages['firestore-security-rules']['class-name']; + +Prism.languages.insertBefore('firestore-security-rules', 'keyword', { + path: { + pattern: + /(^|[\s(),])(?:\/(?:[\w\xA0-\uFFFF]+|\{[\w\xA0-\uFFFF]+(?:=\*\*)?\}|\$\([\w\xA0-\uFFFF.]+\)))+/, + lookbehind: true, + greedy: true, + inside: { + variable: { + pattern: /\{[\w\xA0-\uFFFF]+(?:=\*\*)?\}|\$\([\w\xA0-\uFFFF.]+\)/, + inside: { + operator: /=/, + keyword: /\*\*/, + punctuation: /[.$(){}]/, + }, + }, + punctuation: /\//, + }, + }, + method: { + // to make the pattern shorter, the actual method names are omitted + pattern: /(\ballow\s+)[a-z]+(?:\s*,\s*[a-z]+)*(?=\s*[:;])/, + lookbehind: true, + alias: 'builtin', + inside: { + punctuation: /,/, + }, + }, +}); -- cgit v1.2.3