diff.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. const regex = hljs.regex;
  11. return {
  12. name: 'Diff',
  13. aliases: [ 'patch' ],
  14. contains: [
  15. {
  16. className: 'meta',
  17. relevance: 10,
  18. match: regex.either(
  19. /^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,
  20. /^\*\*\* +\d+,\d+ +\*\*\*\*$/,
  21. /^--- +\d+,\d+ +----$/
  22. )
  23. },
  24. {
  25. className: 'comment',
  26. variants: [
  27. {
  28. begin: regex.either(
  29. /Index: /,
  30. /^index/,
  31. /={3,}/,
  32. /^-{3}/,
  33. /^\*{3} /,
  34. /^\+{3}/,
  35. /^diff --git/
  36. ),
  37. end: /$/
  38. },
  39. { match: /^\*{15}$/ }
  40. ]
  41. },
  42. {
  43. className: 'addition',
  44. begin: /^\+/,
  45. end: /$/
  46. },
  47. {
  48. className: 'deletion',
  49. begin: /^-/,
  50. end: /$/
  51. },
  52. {
  53. className: 'addition',
  54. begin: /^!/,
  55. end: /$/
  56. }
  57. ]
  58. };
  59. }
  60. export { diff as default };