crmsh.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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: { end: '\\s*@?[\\w_][\\w_\\.:-]*' }
  50. }
  51. },
  52. {
  53. begin: '\\b(' + COMMANDS.split(' ').join('|') + ')\\s+',
  54. keywords: COMMANDS,
  55. starts: {
  56. className: 'title',
  57. end: '[\\$\\w_][\\w_-]*'
  58. }
  59. },
  60. {
  61. beginKeywords: PROPERTY_SETS,
  62. starts: {
  63. className: 'title',
  64. end: '\\s*([\\w_-]+:)?'
  65. }
  66. },
  67. hljs.QUOTE_STRING_MODE,
  68. {
  69. className: 'meta',
  70. begin: '(ocf|systemd|service|lsb):[\\w_:-]+',
  71. relevance: 0
  72. },
  73. {
  74. className: 'number',
  75. begin: '\\b\\d+(\\.\\d+)?(ms|s|h|m)?',
  76. relevance: 0
  77. },
  78. {
  79. className: 'literal',
  80. begin: '[-]?(infinity|inf)',
  81. relevance: 0
  82. },
  83. {
  84. className: 'attr',
  85. begin: /([A-Za-z$_#][\w_-]+)=/,
  86. relevance: 0
  87. },
  88. {
  89. className: 'tag',
  90. begin: '</?',
  91. end: '/?>',
  92. relevance: 0
  93. }
  94. ]
  95. };
  96. }
  97. export { crmsh as default };