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. * a string (double and simple quote)
  14. */
  15. 'string': /("|')(\\?.)*?\1/m,
  16. /*
  17. * a git command. It starts with a random prompt finishing by a $, then "git" then some other parameters
  18. * For instance:
  19. * $ git add file.txt
  20. */
  21. 'command': {
  22. pattern: /^.*\$ git .*$/m,
  23. inside: {
  24. /*
  25. * A git command can contain a parameter starting by a single or a double dash followed by a string
  26. * For instance:
  27. * $ git diff --cached
  28. * $ git log -p
  29. */
  30. 'parameter': /\s(--|-)\w+/m
  31. }
  32. },
  33. /*
  34. * Coordinates displayed in a git diff command
  35. * For instance:
  36. * $ git diff
  37. * diff --git file.txt file.txt
  38. * index 6214953..1d54a52 100644
  39. * --- file.txt
  40. * +++ file.txt
  41. * @@ -1 +1,2 @@
  42. * -Here's my tetx file
  43. * +Here's my text file
  44. * +And this is the second line
  45. */
  46. 'coord': /^@@.*@@$/m,
  47. /*
  48. * Regexp to match the changed lines in a git diff output. Check the example above.
  49. */
  50. 'deleted': /^-(?!-).+$/m,
  51. 'inserted': /^\+(?!\+).+$/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. };