l0bsterssg

node.js static responsive blog post generator
Log | Files | Refs | README

nix.js (1153B)


      1 /*
      2 Language: Nix
      3 Author: Domen Kožar <domen@dev.si>
      4 Description: Nix functional language
      5 Website: http://nixos.org/nix
      6 */
      7 
      8 
      9 function nix(hljs) {
     10   var NIX_KEYWORDS = {
     11     keyword:
     12       'rec with let in inherit assert if else then',
     13     literal:
     14       'true false or and null',
     15     built_in:
     16       'import abort baseNameOf dirOf isNull builtins map removeAttrs throw ' +
     17       'toString derivation'
     18   };
     19   var ANTIQUOTE = {
     20     className: 'subst',
     21     begin: /\$\{/,
     22     end: /}/,
     23     keywords: NIX_KEYWORDS
     24   };
     25   var ATTRS = {
     26     begin: /[a-zA-Z0-9-_]+(\s*=)/, returnBegin: true,
     27     relevance: 0,
     28     contains: [
     29       {
     30         className: 'attr',
     31         begin: /\S+/
     32       }
     33     ]
     34   };
     35   var STRING = {
     36     className: 'string',
     37     contains: [ANTIQUOTE],
     38     variants: [
     39       {begin: "''", end: "''"},
     40       {begin: '"', end: '"'}
     41     ]
     42   };
     43   var EXPRESSIONS = [
     44     hljs.NUMBER_MODE,
     45     hljs.HASH_COMMENT_MODE,
     46     hljs.C_BLOCK_COMMENT_MODE,
     47     STRING,
     48     ATTRS
     49   ];
     50   ANTIQUOTE.contains = EXPRESSIONS;
     51   return {
     52     name: 'Nix',
     53     aliases: ["nixos"],
     54     keywords: NIX_KEYWORDS,
     55     contains: EXPRESSIONS
     56   };
     57 }
     58 
     59 module.exports = nix;