From 2e98a024898e07371b98f7cf69944daf5a2e1bfe Mon Sep 17 00:00:00 2001 From: Juanfran Date: Thu, 11 Sep 2014 15:56:40 +0200 Subject: [PATCH] auto increment markdown list number --- app/coffee/modules/common/wisiwyg.coffee | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/coffee/modules/common/wisiwyg.coffee b/app/coffee/modules/common/wisiwyg.coffee index ee3c442b..531ff182 100644 --- a/app/coffee/modules/common/wisiwyg.coffee +++ b/app/coffee/modules/common/wisiwyg.coffee @@ -72,15 +72,14 @@ tgMarkitupDirective = ($rootscope, $rs) -> keepDefault: false replaceWith: (data) -> lastLine = data.textarea.value[0..(data.caretPosition - 1)].split("\n").pop() - match = lastLine.match /^(\s*- ).*/ return "\n#{match[1]}" if match match = lastLine.match /^(\s*\* ).*/ return "\n#{match[1]}" if match - match = lastLine.match /^(\s*1\. ).*/ - return "\n#{match[1]}" if match + match = lastLine.match /^(\d+)\./ + return "\n#{parseInt(match[1], 10) + 1}. " if match return "\n"