CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
nginx.js154 linesDownload Raw Back to languages
1/*2Language: Nginx config3Author: Peter Leonov <gojpeg@yandex.ru>4Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>5Category: config, web6Website: https://www.nginx.com7*/8 9/** @type LanguageFn */10function nginx(hljs) {11  const regex = hljs.regex;12  const VAR = {13    className: 'variable',14    variants: [15      { begin: /\$\d+/ },16      { begin: /\$\{\w+\}/ },17      { begin: regex.concat(/[$@]/, hljs.UNDERSCORE_IDENT_RE) }18    ]19  };20  const LITERALS = [21    "on",22    "off",23    "yes",24    "no",25    "true",26    "false",27    "none",28    "blocked",29    "debug",30    "info",31    "notice",32    "warn",33    "error",34    "crit",35    "select",36    "break",37    "last",38    "permanent",39    "redirect",40    "kqueue",41    "rtsig",42    "epoll",43    "poll",44    "/dev/poll"45  ];46  const DEFAULT = {47    endsWithParent: true,48    keywords: {49      $pattern: /[a-z_]{2,}|\/dev\/poll/,50      literal: LITERALS51    },52    relevance: 0,53    illegal: '=>',54    contains: [55      hljs.HASH_COMMENT_MODE,56      {57        className: 'string',58        contains: [59          hljs.BACKSLASH_ESCAPE,60          VAR61        ],62        variants: [63          {64            begin: /"/,65            end: /"/66          },67          {68            begin: /'/,69            end: /'/70          }71        ]72      },73      // this swallows entire URLs to avoid detecting numbers within74      {75        begin: '([a-z]+):/',76        end: '\\s',77        endsWithParent: true,78        excludeEnd: true,79        contains: [ VAR ]80      },81      {82        className: 'regexp',83        contains: [84          hljs.BACKSLASH_ESCAPE,85          VAR86        ],87        variants: [88          {89            begin: "\\s\\^",90            end: "\\s|\\{|;",91            returnEnd: true92          },93          // regexp locations (~, ~*)94          {95            begin: "~\\*?\\s+",96            end: "\\s|\\{|;",97            returnEnd: true98          },99          // *.example.com100          { begin: "\\*(\\.[a-z\\-]+)+" },101          // sub.example.*102          { begin: "([a-z\\-]+\\.)+\\*" }103        ]104      },105      // IP106      {107        className: 'number',108        begin: '\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b'109      },110      // units111      {112        className: 'number',113        begin: '\\b\\d+[kKmMgGdshdwy]?\\b',114        relevance: 0115      },116      VAR117    ]118  };119 120  return {121    name: 'Nginx config',122    aliases: [ 'nginxconf' ],123    contains: [124      hljs.HASH_COMMENT_MODE,125      {126        beginKeywords: "upstream location",127        end: /;|\{/,128        contains: DEFAULT.contains,129        keywords: { section: "upstream location" }130      },131      {132        className: 'section',133        begin: regex.concat(hljs.UNDERSCORE_IDENT_RE + regex.lookahead(/\s+\{/)),134        relevance: 0135      },136      {137        begin: regex.lookahead(hljs.UNDERSCORE_IDENT_RE + '\\s'),138        end: ';|\\{',139        contains: [140          {141            className: 'attribute',142            begin: hljs.UNDERSCORE_IDENT_RE,143            starts: DEFAULT144          }145        ],146        relevance: 0147      }148    ],149    illegal: '[^\\s\\}\\{]'150  };151}152 153export { nginx as default };154 
basant307/AI_Governance_Project · CoolFace