crmsh.js 2.5 KB

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