crmsh.js 2.2 KB

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