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-nginx.js | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 public/prism/prism-nginx.js (limited to 'public/prism/prism-nginx.js') diff --git a/public/prism/prism-nginx.js b/public/prism/prism-nginx.js new file mode 100644 index 0000000..b43e770 --- /dev/null +++ b/public/prism/prism-nginx.js @@ -0,0 +1,55 @@ +(function (Prism) { + var variable = + /\$(?:\w[a-z\d]*(?:_[^\x00-\x1F\s"'\\()$]*)?|\{[^}\s"'\\]+\})/i; + + Prism.languages.nginx = { + comment: { + pattern: /(^|[\s{};])#.*/, + lookbehind: true, + greedy: true, + }, + directive: { + pattern: + /(^|\s)\w(?:[^;{}"'\\\s]|\\.|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\s+(?:#.*(?!.)|(?![#\s])))*?(?=\s*[;{])/, + lookbehind: true, + greedy: true, + inside: { + string: { + pattern: + /((?:^|[^\\])(?:\\\\)*)(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/, + lookbehind: true, + greedy: true, + inside: { + escape: { + pattern: /\\["'\\nrt]/, + alias: 'entity', + }, + variable: variable, + }, + }, + comment: { + pattern: /(\s)#.*/, + lookbehind: true, + greedy: true, + }, + keyword: { + pattern: /^\S+/, + greedy: true, + }, + + // other patterns + + boolean: { + pattern: /(\s)(?:off|on)(?!\S)/, + lookbehind: true, + }, + number: { + pattern: /(\s)\d+[a-z]*(?!\S)/i, + lookbehind: true, + }, + variable: variable, + }, + }, + punctuation: /[{};]/, + }; +})(Prism); -- cgit v1.2.3