tex.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. module.exports = function(hljs) {
  2. var COMMAND = {
  3. className: 'tag',
  4. begin: /\\/,
  5. relevance: 0,
  6. contains: [
  7. {
  8. className: 'name',
  9. variants: [
  10. {begin: /[a-zA-Z\u0430-\u044f\u0410-\u042f]+[*]?/},
  11. {begin: /[^a-zA-Z\u0430-\u044f\u0410-\u042f0-9]/}
  12. ],
  13. starts: {
  14. endsWithParent: true,
  15. relevance: 0,
  16. contains: [
  17. {
  18. className: 'string', // because it looks like attributes in HTML tags
  19. variants: [
  20. {begin: /\[/, end: /\]/},
  21. {begin: /\{/, end: /\}/}
  22. ]
  23. },
  24. {
  25. begin: /\s*=\s*/, endsWithParent: true,
  26. relevance: 0,
  27. contains: [
  28. {
  29. className: 'number',
  30. begin: /-?\d*\.?\d+(pt|pc|mm|cm|in|dd|cc|ex|em)?/
  31. }
  32. ]
  33. }
  34. ]
  35. }
  36. }
  37. ]
  38. };
  39. return {
  40. contains: [
  41. COMMAND,
  42. {
  43. className: 'formula',
  44. contains: [COMMAND],
  45. relevance: 0,
  46. variants: [
  47. {begin: /\$\$/, end: /\$\$/},
  48. {begin: /\$/, end: /\$/}
  49. ]
  50. },
  51. hljs.COMMENT(
  52. '%',
  53. '$',
  54. {
  55. relevance: 0
  56. }
  57. )
  58. ]
  59. };
  60. };