cm_hl.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: http://codemirror.net/LICENSE
  3. (function (mod) {
  4. mod(require("codemirror"));
  5. })(function (CodeMirror) {
  6. "use strict";
  7. CodeMirror.defineMode('host', function () {
  8. return {
  9. token: function(stream) {
  10. let tw_pos = stream.string.search(/[\t ]+?$/);
  11. //if (!stream.sol() || tw_pos === 0) {
  12. // stream.skipToEnd();
  13. //return ("error " + (TOKEN_NAMES[stream.string.charAt(0)] || '')).replace(/ $/, '');
  14. //}
  15. //console.log(stream.string);
  16. let c = stream.peek();
  17. let token_name;
  18. if (c == '#') {
  19. token_name = 'comment';
  20. //} else if (!stream.string.match(/^\s*[\d\.]+\s+\w/i)) {
  21. } else if (!stream.string.match(/^\s*([\d\.]+|[\da-f:\.%lo]+)\s+\w/i)) {
  22. token_name = 'error';
  23. } else {
  24. token_name = stream.skipToEnd();
  25. }
  26. //let ip = stream.string.match(/^[\d\.]+\s/);
  27. //if (ip) {
  28. // token_name = 'positive';
  29. // stream.pos = ip[0].length - 1;
  30. //}
  31. //if (tw_pos === -1) {
  32. // stream.skipToEnd();
  33. //} else {
  34. // stream.pos = tw_pos;
  35. //}
  36. stream.skipToEnd();
  37. return token_name;
  38. },
  39. lineComment: '#'
  40. };
  41. });
  42. //CodeMirror.defineMIME('text/x-host', 'host');
  43. });