Skip to content

Commit 23c56ca

Browse files
authored
Merge pull request #16 from hackmdio/feature/disable-autoincrement-list-number
Support disableAutoIncrementMarkdownListNumbers option
2 parents 417827e + 805a9fa commit 23c56ca

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

addon/edit/continuelist.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,19 @@
5050
});
5151
replacements[i] = "\n";
5252
} else {
53+
var disableAutoIncrement = cm.getOption("disableAutoIncrementMarkdownListNumbers") || false
5354
var indent = match[1], after = match[5];
5455
var numbered = !(unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0);
55-
var bullet = numbered ? (parseInt(match[3], 10) + 1) + match[4] : match[2].replace("x", " ");
56+
var bullet
57+
if (numbered) {
58+
bullet = (disableAutoIncrement ? 1 : (parseInt(match[3], 10) + 1)) + match[4];
59+
} else {
60+
bullet = match[2].replace("x", " ");
61+
}
5662
after = after.replace('[x]', '[ ]'); // make todo list default unchecked
5763
replacements[i] = "\n" + indent + bullet + after;
5864

59-
if (numbered) incrementRemainingMarkdownListNumbers(cm, pos);
65+
if (numbered && !disableAutoIncrement) incrementRemainingMarkdownListNumbers(cm, pos);
6066
}
6167
}
6268

0 commit comments

Comments
 (0)