diff src/nabble/view/web/util/codemirror/js/parsedummy.js @ 0:7ecd1a4ef557

add content
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 21 Mar 2019 19:15:52 -0600
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/nabble/view/web/util/codemirror/js/parsedummy.js	Thu Mar 21 19:15:52 2019 -0600
@@ -0,0 +1,32 @@
+var DummyParser = Editor.Parser = (function() {
+  function tokenizeDummy(source) {
+    while (!source.endOfLine()) source.next();
+    return "text";
+  }
+  function parseDummy(source) {
+    function indentTo(n) {return function() {return n;}}
+    source = tokenizer(source, tokenizeDummy);
+    var space = 0;
+
+    var iter = {
+      next: function() {
+        var tok = source.next();
+        if (tok.type == "whitespace") {
+          if (tok.value == "\n") tok.indentation = indentTo(space);
+          else space = tok.value.length;
+        }
+        return tok;
+      },
+      copy: function() {
+        var _space = space;
+        return function(_source) {
+          space = _space;
+          source = tokenizer(_source, tokenizeDummy);
+          return iter;
+        };
+      }
+    };
+    return iter;
+  }
+  return {make: parseDummy};
+})();