Browse files

Stops conversion of newlines into <br> tags

  • Loading branch information...
1 parent 0aad9ab commit e5ec8701ff8e1c253e2ab7e85688d83d9c95c201 @calexicoz calexicoz committed Mar 21, 2012
Showing with 1 addition and 17 deletions.
  1. +0 −7 lib/model_formatting.rb
  2. +1 −10 test/model_formatting_test.rb
View
7 lib/model_formatting.rb
@@ -182,13 +182,6 @@ def self.gfm(text)
text.gsub!(/(^(?! {4}|\t)\w+_\w+_\w[\w_]*)/) do |x|
x.gsub('_', '\_') if x.split('').sort.to_s[0..1] == '__'
end
-
- # in very clear cases, let newlines become <br /> tags
- #text.gsub!(/(\A|^$\n)(^\w[^\n]*\n)(^\w[^\n]*$)+/m) do |x|
- # x.gsub(/^(.+)$/, "\\1 ")
- text.gsub!(/^[\w\<][^\n]*\n+/) do |x|
- x =~ /\n{2}/ ? x : (x.strip!; x << " \n")
- end
end
end
View
11 test/model_formatting_test.rb
@@ -88,7 +88,7 @@ class ModelFormattingTest < Test::Unit::TestCase
it "treats linebreaks correctly" do
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 == \
- "<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>"
+ "<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>"
end
describe "GFM" do
@@ -108,15 +108,6 @@ class ModelFormattingTest < Test::Unit::TestCase
assert_equal "foo\\_bar\\_baz", ModelFormatting.gfm("foo_bar_baz")
end
- it "turns newlines into br tags in simple cases" do
- assert_equal "foo \nbar", ModelFormatting.gfm("foo\nbar")
- end
-
- it "converts newlines in all groups" do
- assert_equal "apple \npear \norange \nbanana\n\nruby \npython \nerlang \njavascript",
- ModelFormatting.gfm("apple\npear\norange\nbanana\n\nruby\npython\nerlang\njavascript")
- end
-
it "does not not convert newlines in lists" do
assert_equal "# foo\n# bar", ModelFormatting.gfm("# foo\n# bar")
assert_equal "* foo\n* bar", ModelFormatting.gfm("* foo\n* bar")

0 comments on commit e5ec870

Please sign in to comment.