prism-t4-templating.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. (function (Prism) {
  2. function createBlock(prefix, inside, contentAlias) {
  3. return {
  4. pattern: RegExp('<#' + prefix + '[\\s\\S]*?#>'),
  5. alias: 'block',
  6. inside: {
  7. 'delimiter': {
  8. pattern: RegExp('^<#' + prefix + '|#>$'),
  9. alias: 'important'
  10. },
  11. 'content': {
  12. pattern: /[\s\S]+/,
  13. inside: inside,
  14. alias: contentAlias
  15. }
  16. }
  17. };
  18. }
  19. function createT4(insideLang) {
  20. var grammar = Prism.languages[insideLang];
  21. var className = 'language-' + insideLang;
  22. return {
  23. 'block': {
  24. pattern: /<#[\s\S]+?#>/,
  25. inside: {
  26. 'directive': createBlock('@', {
  27. 'attr-value': {
  28. pattern: /=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+)/,
  29. inside: {
  30. 'punctuation': /^=|^["']|["']$/
  31. }
  32. },
  33. 'keyword': /\b\w+(?=\s)/,
  34. 'attr-name': /\b\w+/
  35. }),
  36. 'expression': createBlock('=', grammar, className),
  37. 'class-feature': createBlock('\\+', grammar, className),
  38. 'standard': createBlock('', grammar, className)
  39. }
  40. }
  41. };
  42. }
  43. Prism.languages['t4-templating'] = Object.defineProperty({}, 'createT4', { value: createT4 });
  44. }(Prism));