2 CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
3 var pos = cm.getCursor(), token = cm.getTokenAt(pos);
5 if (token.className == "string") {
6 var full = cm.getRange({line: pos.line, ch: 0}, {line: pos.line, ch: token.end});
7 var listStart = /\*|\d+\./, listContinue;
8 if (token.string.search(listStart) == 0) {
9 var reg = /^[\W]*(\d+)\./g;
10 var matches = reg.exec(full);
12 listContinue = (parseInt(matches[1]) + 1) + ". ";
15 space = full.slice(0, token.start);
16 if (!/^\s*$/.test(space)) {
18 for (var i = 0; i < token.start; ++i) space += " ";
24 cm.replaceSelection("\n" + space + listContinue, "end");
26 cm.execCommand("newlineAndIndent");