prism-git.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. Prism.languages.git = {
  2. /*
  3. * A simple one line comment like in a git status command
  4. * For instance:
  5. * $ git status
  6. * # On branch infinite-scroll
  7. * # Your branch and 'origin/sharedBranches/frontendTeam/infinite-scroll' have diverged,
  8. * # and have 1 and 2 different commits each, respectively.
  9. * nothing to commit (working directory clean)
  10. */
  11. 'comment': /^#.*/m,
  12. /*
  13. * Regexp to match the changed lines in a git diff output. Check the example below.
  14. */
  15. 'deleted': /^[-–].*/m,
  16. 'inserted': /^\+.*/m,
  17. /*
  18. * a string (double and simple quote)
  19. */
  20. 'string': /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
  21. /*
  22. * a git command. It starts with a random prompt finishing by a $, then "git" then some other parameters
  23. * For instance:
  24. * $ git add file.txt
  25. */
  26. 'command': {
  27. pattern: /^.*\$ git .*$/m,
  28. inside: {
  29. /*
  30. * A git command can contain a parameter starting by a single or a double dash followed by a string
  31. * For instance:
  32. * $ git diff --cached
  33. * $ git log -p
  34. */
  35. 'parameter': /\s--?\w+/
  36. }
  37. },
  38. /*
  39. * Coordinates displayed in a git diff command
  40. * For instance:
  41. * $ git diff
  42. * diff --git file.txt file.txt
  43. * index 6214953..1d54a52 100644
  44. * --- file.txt
  45. * +++ file.txt
  46. * @@ -1 +1,2 @@
  47. * -Here's my tetx file
  48. * +Here's my text file
  49. * +And this is the second line
  50. */
  51. 'coord': /^@@.*@@$/m,
  52. /*
  53. * Match a "commit [SHA1]" line in a git log output.
  54. * For instance:
  55. * $ git log
  56. * commit a11a14ef7e26f2ca62d4b35eac455ce636d0dc09
  57. * Author: lgiraudel
  58. * Date: Mon Feb 17 11:18:34 2014 +0100
  59. *
  60. * Add of a new line
  61. */
  62. 'commit-sha1': /^commit \w{40}$/m
  63. };