l0bsterssg

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

crmsh.js (2510B)


      1 /*
      2 Language: crmsh
      3 Author: Kristoffer Gronlund <kgronlund@suse.com>
      4 Website: http://crmsh.github.io
      5 Description: Syntax Highlighting for the crmsh DSL
      6 Category: config
      7 */
      8 
      9 /** @type LanguageFn */
     10 function crmsh(hljs) {
     11   var RESOURCES = 'primitive rsc_template';
     12 
     13   var COMMANDS = 'group clone ms master location colocation order fencing_topology ' +
     14       'rsc_ticket acl_target acl_group user role ' +
     15       'tag xml';
     16 
     17   var PROPERTY_SETS = 'property rsc_defaults op_defaults';
     18 
     19   var KEYWORDS = 'params meta operations op rule attributes utilization';
     20 
     21   var OPERATORS = 'read write deny defined not_defined in_range date spec in ' +
     22       'ref reference attribute type xpath version and or lt gt tag ' +
     23       'lte gte eq ne \\';
     24 
     25   var TYPES = 'number string';
     26 
     27   var LITERALS = 'Master Started Slave Stopped start promote demote stop monitor true false';
     28 
     29   return {
     30     name: 'crmsh',
     31     aliases: ['crm', 'pcmk'],
     32     case_insensitive: true,
     33     keywords: {
     34       keyword: KEYWORDS + ' ' + OPERATORS + ' ' + TYPES,
     35       literal: LITERALS
     36     },
     37     contains: [
     38       hljs.HASH_COMMENT_MODE,
     39       {
     40         beginKeywords: 'node',
     41         starts: {
     42           end: '\\s*([\\w_-]+:)?',
     43           starts: {
     44             className: 'title',
     45             end: '\\s*[\\$\\w_][\\w_-]*'
     46           }
     47         }
     48       },
     49       {
     50         beginKeywords: RESOURCES,
     51         starts: {
     52           className: 'title',
     53           end: '\\s*[\\$\\w_][\\w_-]*',
     54           starts: {
     55             end: '\\s*@?[\\w_][\\w_\\.:-]*'
     56           }
     57         }
     58       },
     59       {
     60         begin: '\\b(' + COMMANDS.split(' ').join('|') + ')\\s+',
     61         keywords: COMMANDS,
     62         starts: {
     63           className: 'title',
     64           end: '[\\$\\w_][\\w_-]*'
     65         }
     66       },
     67       {
     68         beginKeywords: PROPERTY_SETS,
     69         starts: {
     70           className: 'title',
     71           end: '\\s*([\\w_-]+:)?'
     72         }
     73       },
     74       hljs.QUOTE_STRING_MODE,
     75       {
     76         className: 'meta',
     77         begin: '(ocf|systemd|service|lsb):[\\w_:-]+',
     78         relevance: 0
     79       },
     80       {
     81         className: 'number',
     82         begin: '\\b\\d+(\\.\\d+)?(ms|s|h|m)?',
     83         relevance: 0
     84       },
     85       {
     86         className: 'literal',
     87         begin: '[-]?(infinity|inf)',
     88         relevance: 0
     89       },
     90       {
     91         className: 'attr',
     92         begin: /([A-Za-z\$_\#][\w_-]+)=/,
     93         relevance: 0
     94       },
     95       {
     96         className: 'tag',
     97         begin: '</?',
     98         end: '/?>',
     99         relevance: 0
    100       }
    101     ]
    102   };
    103 }
    104 
    105 module.exports = crmsh;