From 74a76001819c8c72d5cb815dac0479d4de90754f Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Mon, 9 May 2016 10:27:51 +0700 Subject: [PATCH] Markdown indentation fix It was bugging on some weird cases. --- lib/markdown.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/markdown.coffee b/lib/markdown.coffee index 6af7759..a332eeb 100644 --- a/lib/markdown.coffee +++ b/lib/markdown.coffee @@ -4,7 +4,7 @@ Implies that you don't mix up your tabs and spaces. Copyright 2015 Bruno Dias ### normaliseTabs = (text) -> - unless text? and typeof(text) == "string" + if not text? or typeof(text) != "string" or text == "" return "" lines = text.split('\n'); indents = lines @@ -20,6 +20,8 @@ normaliseTabs = (text) -> return curr return max ) + if smallestIndent == "" + return text return lines.map((l) -> return l.replace(new RegExp('^' + smallestIndent), '') ).join('\n')