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-css.js | 76 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 public/prism/prism-css.js (limited to 'public/prism/prism-css.js') diff --git a/public/prism/prism-css.js b/public/prism/prism-css.js new file mode 100644 index 0000000..1785a57 --- /dev/null +++ b/public/prism/prism-css.js @@ -0,0 +1,76 @@ +(function (Prism) { + var string = + /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/; + + Prism.languages.css = { + comment: /\/\*[\s\S]*?\*\//, + atrule: { + pattern: /@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/, + inside: { + rule: /^@[\w-]+/, + 'selector-function-argument': { + pattern: + /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/, + lookbehind: true, + alias: 'selector', + }, + keyword: { + pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/, + lookbehind: true, + }, + // See rest below + }, + }, + url: { + // https://drafts.csswg.org/css-values-3/#urls + pattern: RegExp( + '\\burl\\((?:' + + string.source + + '|' + + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + + ')\\)', + 'i' + ), + greedy: true, + inside: { + function: /^url/i, + punctuation: /^\(|\)$/, + string: { + pattern: RegExp('^' + string.source + '$'), + alias: 'url', + }, + }, + }, + selector: { + pattern: RegExp( + '(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + + string.source + + ')*(?=\\s*\\{)' + ), + lookbehind: true, + }, + string: { + pattern: string, + greedy: true, + }, + property: { + pattern: + /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i, + lookbehind: true, + }, + important: /!important\b/i, + function: { + pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i, + lookbehind: true, + }, + punctuation: /[(){};:,]/, + }; + + Prism.languages.css['atrule'].inside.rest = Prism.languages.css; + + var markup = Prism.languages.markup; + if (markup) { + markup.tag.addInlined('style', 'css'); + markup.tag.addAttribute('style', 'css'); + } +})(Prism); -- cgit v1.2.3