From f84630a54d273d823c0b799dc147aeddc377f79e Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 26 Aug 2013 11:42:52 -0400 Subject: [PATCH] FIX: New line insertion when a line begins with [] --- .../javascripts/discourse/components/markdown.js | 2 +- test/javascripts/components/markdown_test.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/components/markdown.js b/app/assets/javascripts/discourse/components/markdown.js index 57fb2e0dd..e6373a934 100644 --- a/app/assets/javascripts/discourse/components/markdown.js +++ b/app/assets/javascripts/discourse/components/markdown.js @@ -100,7 +100,7 @@ Discourse.Markdown = { // Linebreaks var linebreaks = opts.traditional_markdown_linebreaks || Discourse.SiteSettings.traditional_markdown_linebreaks; if (!linebreaks) { - text = text.replace(/(^[\w<][^\n]*\n+)/gim, function(t) { + text = text.replace(/(^[\w<\[][^\n]*\n+)/gim, function(t) { if (t.match(/\n{2}/gim)) return t; return t.replace("\n", " \n"); }); diff --git a/test/javascripts/components/markdown_test.js b/test/javascripts/components/markdown_test.js index e0840812f..021714cc1 100644 --- a/test/javascripts/components/markdown_test.js +++ b/test/javascripts/components/markdown_test.js @@ -20,7 +20,7 @@ test("basic cooking", function() { cooked("***hello***", "

hello

", "it can do bold and italics at once."); }); -test("Line Breaks", function() { +test("Traditional Line Breaks", function() { var input = "1\n2\n3"; cooked(input, "

1
2
3

", "automatically handles trivial newlines"); @@ -34,9 +34,16 @@ test("Line Breaks", function() { Discourse.SiteSettings.traditional_markdown_linebreaks = true; cooked(input, traditionalOutput, "It supports traditional markdown via a Site Setting"); - }); +test("Line Breaks", function() { + + cooked("[] first choice\n[] second choice", + "

[] first choice
[] second choice

", + "it handles new lines correctly with [] options"); +}); + + test("Links", function() { cooked("EvilTrout: http://eviltrout.com",