diff.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. Language: Diff
  3. Description: Unified and context diff
  4. Author: Vasily Polovnyov <vast@whiteants.net>
  5. Website: https://www.gnu.org/software/diffutils/
  6. Category: common
  7. */
  8. /** @type LanguageFn */
  9. function diff(hljs) {
  10. return {
  11. name: 'Diff',
  12. aliases: ['patch'],
  13. contains: [
  14. {
  15. className: 'meta',
  16. relevance: 10,
  17. variants: [
  18. {
  19. begin: /^@@ +-\d+,\d+ +\+\d+,\d+ +@@/
  20. },
  21. {
  22. begin: /^\*\*\* +\d+,\d+ +\*\*\*\*$/
  23. },
  24. {
  25. begin: /^--- +\d+,\d+ +----$/
  26. }
  27. ]
  28. },
  29. {
  30. className: 'comment',
  31. variants: [
  32. {
  33. begin: /Index: /,
  34. end: /$/
  35. },
  36. {
  37. begin: /^index/,
  38. end: /$/
  39. },
  40. {
  41. begin: /={3,}/,
  42. end: /$/
  43. },
  44. {
  45. begin: /^-{3}/,
  46. end: /$/
  47. },
  48. {
  49. begin: /^\*{3} /,
  50. end: /$/
  51. },
  52. {
  53. begin: /^\+{3}/,
  54. end: /$/
  55. },
  56. {
  57. begin: /^\*{15}$/
  58. },
  59. {
  60. begin: /^diff --git/,
  61. end: /$/
  62. }
  63. ]
  64. },
  65. {
  66. className: 'addition',
  67. begin: /^\+/,
  68. end: /$/
  69. },
  70. {
  71. className: 'deletion',
  72. begin: /^-/,
  73. end: /$/
  74. },
  75. {
  76. className: 'addition',
  77. begin: /^!/,
  78. end: /$/
  79. }
  80. ]
  81. };
  82. }
  83. module.exports = diff;