l0bsterssg

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

elm.js (2125B)


      1 /*
      2 Language: Elm
      3 Author: Janis Voigtlaender <janis.voigtlaender@gmail.com>
      4 Website: https://elm-lang.org
      5 Category: functional
      6 */
      7 
      8 function elm(hljs) {
      9   var COMMENT = {
     10     variants: [
     11       hljs.COMMENT('--', '$'),
     12       hljs.COMMENT(
     13         '{-',
     14         '-}',
     15         {
     16           contains: ['self']
     17         }
     18       )
     19     ]
     20   };
     21 
     22   var CONSTRUCTOR = {
     23     className: 'type',
     24     begin: '\\b[A-Z][\\w\']*', // TODO: other constructors (built-in, infix).
     25     relevance: 0
     26   };
     27 
     28   var LIST = {
     29     begin: '\\(', end: '\\)',
     30     illegal: '"',
     31     contains: [
     32       {className: 'type', begin: '\\b[A-Z][\\w]*(\\((\\.\\.|,|\\w+)\\))?'},
     33       COMMENT
     34     ]
     35   };
     36 
     37   var RECORD = {
     38     begin: '{', end: '}',
     39     contains: LIST.contains
     40   };
     41 
     42   var CHARACTER = {
     43     className: 'string',
     44     begin: '\'\\\\?.', end: '\'',
     45     illegal: '.'
     46   };
     47 
     48   return {
     49     name: 'Elm',
     50     keywords:
     51       'let in if then else case of where module import exposing ' +
     52       'type alias as infix infixl infixr port effect command subscription',
     53     contains: [
     54 
     55       // Top-level constructions.
     56 
     57       {
     58         beginKeywords: 'port effect module', end: 'exposing',
     59         keywords: 'port effect module where command subscription exposing',
     60         contains: [LIST, COMMENT],
     61         illegal: '\\W\\.|;'
     62       },
     63       {
     64         begin: 'import', end: '$',
     65         keywords: 'import as exposing',
     66         contains: [LIST, COMMENT],
     67         illegal: '\\W\\.|;'
     68       },
     69       {
     70         begin: 'type', end: '$',
     71         keywords: 'type alias',
     72         contains: [CONSTRUCTOR, LIST, RECORD, COMMENT]
     73       },
     74       {
     75         beginKeywords: 'infix infixl infixr', end: '$',
     76         contains: [hljs.C_NUMBER_MODE, COMMENT]
     77       },
     78       {
     79         begin: 'port', end: '$',
     80         keywords: 'port',
     81         contains: [COMMENT]
     82       },
     83 
     84       // Literals and names.
     85 
     86       CHARACTER,
     87       hljs.QUOTE_STRING_MODE,
     88       hljs.C_NUMBER_MODE,
     89       CONSTRUCTOR,
     90       hljs.inherit(hljs.TITLE_MODE, {begin: '^[_a-z][\\w\']*'}),
     91       COMMENT,
     92 
     93       {begin: '->|<-'} // No markup, relevance booster
     94     ],
     95     illegal: /;/
     96   };
     97 }
     98 
     99 module.exports = elm;