dart.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. module.exports = function(hljs) {
  2. var SUBST = {
  3. className: 'subst',
  4. variants: [{
  5. begin: '\\$[A-Za-z0-9_]+'
  6. }],
  7. };
  8. var BRACED_SUBST = {
  9. className: 'subst',
  10. variants: [{
  11. begin: '\\${',
  12. end: '}'
  13. }, ],
  14. keywords: 'true false null this is new super',
  15. };
  16. var STRING = {
  17. className: 'string',
  18. variants: [{
  19. begin: 'r\'\'\'',
  20. end: '\'\'\''
  21. },
  22. {
  23. begin: 'r"""',
  24. end: '"""'
  25. },
  26. {
  27. begin: 'r\'',
  28. end: '\'',
  29. illegal: '\\n'
  30. },
  31. {
  32. begin: 'r"',
  33. end: '"',
  34. illegal: '\\n'
  35. },
  36. {
  37. begin: '\'\'\'',
  38. end: '\'\'\'',
  39. contains: [hljs.BACKSLASH_ESCAPE, SUBST, BRACED_SUBST]
  40. },
  41. {
  42. begin: '"""',
  43. end: '"""',
  44. contains: [hljs.BACKSLASH_ESCAPE, SUBST, BRACED_SUBST]
  45. },
  46. {
  47. begin: '\'',
  48. end: '\'',
  49. illegal: '\\n',
  50. contains: [hljs.BACKSLASH_ESCAPE, SUBST, BRACED_SUBST]
  51. },
  52. {
  53. begin: '"',
  54. end: '"',
  55. illegal: '\\n',
  56. contains: [hljs.BACKSLASH_ESCAPE, SUBST, BRACED_SUBST]
  57. }
  58. ]
  59. };
  60. BRACED_SUBST.contains = [
  61. hljs.C_NUMBER_MODE, STRING
  62. ];
  63. var KEYWORDS = {
  64. keyword: 'abstract as assert async await break case catch class const continue covariant default deferred do ' +
  65. 'dynamic else enum export extends extension external factory false final finally for Function get hide if ' +
  66. 'implements import in inferface is library mixin new null on operator part rethrow return set show static ' +
  67. 'super switch sync this throw true try typedef var void while with yield',
  68. built_in:
  69. // dart:core
  70. 'Comparable DateTime Duration Function Iterable Iterator List Map Match Null Object Pattern RegExp Set ' +
  71. 'Stopwatch String StringBuffer StringSink Symbol Type Uri bool double dynamic int num print ' +
  72. // dart:html
  73. 'Element ElementList document querySelector querySelectorAll window'
  74. };
  75. return {
  76. keywords: KEYWORDS,
  77. contains: [
  78. STRING,
  79. hljs.COMMENT(
  80. '/\\*\\*',
  81. '\\*/', {
  82. subLanguage: 'markdown'
  83. }
  84. ),
  85. hljs.COMMENT(
  86. '///+\\s*',
  87. '$', {
  88. contains: [{
  89. subLanguage: 'markdown',
  90. begin: '.',
  91. end: '$',
  92. }]
  93. }
  94. ),
  95. hljs.C_LINE_COMMENT_MODE,
  96. hljs.C_BLOCK_COMMENT_MODE,
  97. {
  98. className: 'class',
  99. beginKeywords: 'class interface',
  100. end: '{',
  101. excludeEnd: true,
  102. contains: [{
  103. beginKeywords: 'extends implements'
  104. },
  105. hljs.UNDERSCORE_TITLE_MODE
  106. ]
  107. },
  108. hljs.C_NUMBER_MODE,
  109. {
  110. className: 'meta',
  111. begin: '@[A-Za-z]+'
  112. },
  113. {
  114. begin: '=>' // No markup, just a relevance booster
  115. }
  116. ]
  117. }
  118. };