Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | (function() { CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) { var pos = cm.getCursor(), token = cm.getTokenAt(pos); var space; if (token.className == "string") { var full = cm.getRange({line: pos.line, ch: 0}, {line: pos.line, ch: token.end}); var listStart = /\*|\d+\./, listContinue; if (token.string.search(listStart) == 0) { var reg = /^[\W]*(\d+)\./g; var matches = reg.exec(full); if(matches) listContinue = (parseInt(matches[1]) + 1) + ". "; else listContinue = "* "; space = full.slice(0, token.start); if (!/^\s*$/.test(space)) { space = ""; for (var i = 0; i < token.start; ++i) space += " "; } } } if (space != null) cm.replaceSelection("\n" + space + listContinue, "end"); else cm.execCommand("newlineAndIndent"); }; })(); |