Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Stops conversion of newlines into <br> tags

  • Loading branch information...
commit e5ec8701ff8e1c253e2ab7e85688d83d9c95c201 1 parent 0aad9ab
Julien calexicoz authored

Showing 2 changed files with 1 addition and 17 deletions. Show diff stats Hide diff stats

  1. +0 7 lib/model_formatting.rb
  2. +1 10 test/model_formatting_test.rb
7 lib/model_formatting.rb
@@ -182,13 +182,6 @@ def self.gfm(text)
182 182 text.gsub!(/(^(?! {4}|\t)\w+_\w+_\w[\w_]*)/) do |x|
183 183 x.gsub('_', '\_') if x.split('').sort.to_s[0..1] == '__'
184 184 end
185   -
186   - # in very clear cases, let newlines become <br /> tags
187   - #text.gsub!(/(\A|^$\n)(^\w[^\n]*\n)(^\w[^\n]*$)+/m) do |x|
188   - # x.gsub(/^(.+)$/, "\\1 ")
189   - text.gsub!(/^[\w\<][^\n]*\n+/) do |x|
190   - x =~ /\n{2}/ ? x : (x.strip!; x << " \n")
191   - end
192 185 end
193 186 end
194 187
11 test/model_formatting_test.rb
@@ -88,7 +88,7 @@ class ModelFormattingTest < Test::Unit::TestCase
88 88
89 89 it "treats linebreaks correctly" do
90 90 ModelFormatting.process(:html, "Line breaks should not be treated as\nnew paragraphs. They are not paragraphs.\n\nHowever, when a line is skipped, that is a paragraph.\nGMail, and basically every comment or submission form on the \nweb work this way.").should == \
91   - "<div><p>Line breaks should not be treated as<br/>\nnew paragraphs. They are not paragraphs.</p>\n\n<p>However, when a line is skipped, that is a paragraph.<br/>\nGMail, and basically every comment or submission form on the<br/>\nweb work this way.</p></div>"
  91 + "<div><p>Line breaks should not be treated as\nnew paragraphs. They are not paragraphs.</p>\n\n<p>However, when a line is skipped, that is a paragraph.\nGMail, and basically every comment or submission form on the\nweb work this way.</p></div>"
92 92 end
93 93
94 94 describe "GFM" do
@@ -108,15 +108,6 @@ class ModelFormattingTest < Test::Unit::TestCase
108 108 assert_equal "foo\\_bar\\_baz", ModelFormatting.gfm("foo_bar_baz")
109 109 end
110 110
111   - it "turns newlines into br tags in simple cases" do
112   - assert_equal "foo \nbar", ModelFormatting.gfm("foo\nbar")
113   - end
114   -
115   - it "converts newlines in all groups" do
116   - assert_equal "apple \npear \norange \nbanana\n\nruby \npython \nerlang \njavascript",
117   - ModelFormatting.gfm("apple\npear\norange\nbanana\n\nruby\npython\nerlang\njavascript")
118   - end
119   -
120 111 it "does not not convert newlines in lists" do
121 112 assert_equal "# foo\n# bar", ModelFormatting.gfm("# foo\n# bar")
122 113 assert_equal "* foo\n* bar", ModelFormatting.gfm("* foo\n* bar")

0 comments on commit e5ec870

Please sign in to comment.
Something went wrong with that request. Please try again.