2
0

diff.js 677 B

1234567891011121314151617181920212223242526272829303132
  1. CodeMirror.defineMode("diff", function() {
  2. var TOKEN_NAMES = {
  3. '+': 'positive',
  4. '-': 'negative',
  5. '@': 'meta'
  6. };
  7. return {
  8. token: function(stream) {
  9. var tw_pos = stream.string.search(/[\t ]+?$/);
  10. if (!stream.sol() || tw_pos === 0) {
  11. stream.skipToEnd();
  12. return ("error " + (
  13. TOKEN_NAMES[stream.string.charAt(0)] || '')).replace(/ $/, '');
  14. }
  15. var token_name = TOKEN_NAMES[stream.peek()] || stream.skipToEnd();
  16. if (tw_pos === -1) {
  17. stream.skipToEnd();
  18. } else {
  19. stream.pos = tw_pos;
  20. }
  21. return token_name;
  22. }
  23. };
  24. });
  25. CodeMirror.defineMIME("text/x-diff", "diff");