Permalink
Browse files

Removed textilize, textilize_without_paragraph and markdown helpers

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent f48aa14 commit 0919c0dbca3df02f5cfff7dde4f61b85ef16d886 @spastorino spastorino committed with josevalim Jun 9, 2010
Showing with 2 additions and 195 deletions.
  1. +0 −4 Gemfile
  2. +2 −0 actionpack/CHANGELOG
  3. +0 −83 actionpack/lib/action_view/helpers/text_helper.rb
  4. +0 −108 actionpack/test/template/text_helper_test.rb
View
@@ -44,10 +44,6 @@ elsif RUBY_ENGINE == "jruby"
end
end
-# AP
-gem "RedCloth", ">= 4.2.2"
-gem "bluecloth", ">= 2.0.7"
-
group :documentation do
gem 'rdoc', '2.1'
end
@@ -1,3 +1,5 @@
+* Removed textilize, textilize_without_paragraph and markdown helpers. [Santiago Pastorino]
+
*Rails 3.0.0 [beta 4] (June 8th, 2010)*
* Remove middleware laziness [José Valim]
@@ -220,89 +220,6 @@ def word_wrap(text, *args)
end * "\n"
end
- # Returns the text with all the Textile[http://www.textism.com/tools/textile] codes turned into HTML tags.
- #
- # You can learn more about Textile's syntax at its website[http://www.textism.com/tools/textile].
- # <i>This method is only available if RedCloth[http://redcloth.org/] is available</i>.
- #
- # ==== Examples
- # textilize("*This is Textile!* Rejoice!")
- # # => "<p><strong>This is Textile!</strong> Rejoice!</p>"
- #
- # textilize("I _love_ ROR(Ruby on Rails)!")
- # # => "<p>I <em>love</em> <acronym title="Ruby on Rails">ROR</acronym>!</p>"
- #
- # textilize("h2. Textile makes markup -easy- simple!")
- # # => "<h2>Textile makes markup <del>easy</del> simple!</h2>"
- #
- # textilize("Visit the Rails website "here":http://www.rubyonrails.org/.)
- # # => "<p>Visit the Rails website <a href="http://www.rubyonrails.org/">here</a>.</p>"
- #
- # textilize("This is worded <strong>strongly</strong>")
- # # => "<p>This is worded <strong>strongly</strong></p>"
- #
- # textilize("This is worded <strong>strongly</strong>", :filter_html)
- # # => "<p>This is worded &lt;strong&gt;strongly&lt;/strong&gt;</p>"
- #
- def textilize(text, *options)
- options ||= [:hard_breaks]
- text = sanitize(text) unless text.html_safe? || options.delete(:safe)
-
- if text.blank?
- ""
- else
- textilized = RedCloth.new(text, options)
- textilized.to_html
- end.html_safe
- end
-
- # Returns the text with all the Textile codes turned into HTML tags,
- # but without the bounding <p> tag that RedCloth adds.
- #
- # You can learn more about Textile's syntax at its website[http://www.textism.com/tools/textile].
- # <i>This method is only available if RedCloth[http://redcloth.org/] is available</i>.
- #
- # ==== Examples
- # textilize_without_paragraph("*This is Textile!* Rejoice!")
- # # => "<strong>This is Textile!</strong> Rejoice!"
- #
- # textilize_without_paragraph("I _love_ ROR(Ruby on Rails)!")
- # # => "I <em>love</em> <acronym title="Ruby on Rails">ROR</acronym>!"
- #
- # textilize_without_paragraph("h2. Textile makes markup -easy- simple!")
- # # => "<h2>Textile makes markup <del>easy</del> simple!</h2>"
- #
- # textilize_without_paragraph("Visit the Rails website "here":http://www.rubyonrails.org/.)
- # # => "Visit the Rails website <a href="http://www.rubyonrails.org/">here</a>."
- def textilize_without_paragraph(text, *options)
- textiled = textilize(text, *options)
- if textiled[0..2] == "<p>" then textiled = textiled[3..-1] end
- if textiled[-4..-1] == "</p>" then textiled = textiled[0..-5] end
- return textiled
- end
-
- # Returns the text with all the Markdown codes turned into HTML tags.
- # <i>This method requires BlueCloth[http://www.deveiate.org/projects/BlueCloth]
- # to be available</i>.
- #
- # ==== Examples
- # markdown("We are using __Markdown__ now!")
- # # => "<p>We are using <strong>Markdown</strong> now!</p>"
- #
- # markdown("We like to _write_ `code`, not just _read_ it!")
- # # => "<p>We like to <em>write</em> <code>code</code>, not just <em>read</em> it!</p>"
- #
- # markdown("The [Markdown website](http://daringfireball.net/projects/markdown/) has more information.")
- # # => "<p>The <a href="http://daringfireball.net/projects/markdown/">Markdown website</a>
- # # has more information.</p>"
- #
- # markdown('![The ROR logo](http://rubyonrails.com/images/rails.png "Ruby on Rails")')
- # # => '<p><img src="http://rubyonrails.com/images/rails.png" alt="The ROR logo" title="Ruby on Rails" /></p>'
- def markdown(text, *options)
- text = sanitize(text) unless text.html_safe? || options.delete(:safe)
- (text.blank? ? "" : BlueCloth.new(text).to_html).html_safe
- end
-
# Returns +text+ transformed into HTML using simple formatting rules.
# Two or more consecutive newlines(<tt>\n\n</tt>) are considered as a
# paragraph and wrapped in <tt><p></tt> tags. One newline (<tt>\n</tt>) is
@@ -1,17 +1,6 @@
# encoding: us-ascii
require 'abstract_unit'
require 'testing_sandbox'
-begin
- require 'redcloth'
-rescue LoadError
- $stderr.puts "Skipping textilize tests. `gem install RedCloth` to enable."
-end
-
-begin
- require 'bluecloth'
-rescue LoadError
- $stderr.puts "Skipping markdown tests. 'gem install bluecloth' to enable."
-end
class TextHelperTest < ActionView::TestCase
tests ActionView::Helpers::TextHelper
@@ -665,101 +654,4 @@ def test_cycle_no_instance_variable_clashes
assert_equal("red", cycle("red", "blue"))
assert_equal(%w{Specialized Fuji Giant}, @cycles)
end
-
- # TODO test textilize_without_paragraph and markdown
- if defined? RedCloth
- def test_textilize_should_be_html_safe
- assert textilize("*This is Textile!* Rejoice!").html_safe?
- end
-
- def test_textilize
- assert_equal("<p><strong>This is Textile!</strong> Rejoice!</p>", textilize("*This is Textile!* Rejoice!"))
- end
-
- def test_textilize_with_blank
- assert_equal("", textilize(""))
- end
-
- def test_textilize_with_options
- assert_equal("<p>This is worded &lt;strong&gt;strongly&lt;/strong&gt;</p>", textilize("This is worded <strong>strongly</strong>", :filter_html))
- end
-
- def test_textilize_should_sanitize_unsafe_input
- assert_equal("<p>This is worded <strong>strongly</strong></p>", textilize("This is worded <strong>strongly</strong><script>code!</script>"))
- end
-
- def test_textilize_should_not_sanitize_input_if_safe_option
- assert_equal("<p>This is worded <strong>strongly</strong><script>code!</script></p>", textilize("This is worded <strong>strongly</strong><script>code!</script>", :safe))
- end
-
- def test_textilize_should_not_sanitize_safe_input
- assert_equal("<p>This is worded <strong>strongly</strong><script>code!</script></p>", textilize("This is worded <strong>strongly</strong><script>code!</script>".html_safe))
- end
-
- def test_textilize_with_hard_breaks
- assert_equal("<p>This is one scary world.<br />\n True.</p>", textilize("This is one scary world.\n True."))
- end
-
- def test_textilize_without_paragraph_should_be_html_safe
- textilize_without_paragraph("*This is Textile!* Rejoice!").html_safe?
- end
-
- def test_textilize_without_paragraph
- assert_equal("<strong>This is Textile!</strong> Rejoice!", textilize_without_paragraph("*This is Textile!* Rejoice!"))
- end
-
- def test_textilize_without_paragraph_with_blank
- assert_equal("", textilize_without_paragraph(""))
- end
-
- def test_textilize_without_paragraph_with_options
- assert_equal("This is worded &lt;strong&gt;strongly&lt;/strong&gt;", textilize_without_paragraph("This is worded <strong>strongly</strong>", :filter_html))
- end
-
- def test_textilize_without_paragraph_should_sanitize_unsafe_input
- assert_equal("This is worded <strong>strongly</strong>", textilize_without_paragraph("This is worded <strong>strongly</strong><script>code!</script>"))
- end
-
- def test_textilize_without_paragraph_should_not_sanitize_input_if_safe_option
- assert_equal("This is worded <strong>strongly</strong><script>code!</script>", textilize_without_paragraph("This is worded <strong>strongly</strong><script>code!</script>", :safe))
- end
-
- def test_textilize_without_paragraph_should_not_sanitize_safe_input
- assert_equal("This is worded <strong>strongly</strong><script>code!</script>", textilize_without_paragraph("This is worded <strong>strongly</strong><script>code!</script>".html_safe))
- end
-
- def test_textilize_without_paragraph_with_hard_breaks
- assert_equal("This is one scary world.<br />\n True.", textilize_without_paragraph("This is one scary world.\n True."))
- end
- end
-
- if defined? BlueCloth
- def test_markdown_should_be_html_safe
- assert markdown("We are using __Markdown__ now!").html_safe?
- end
-
- def test_markdown
- assert_equal("<p>We are using <strong>Markdown</strong> now!</p>", markdown("We are using __Markdown__ now!"))
- end
-
- def test_markdown_with_blank
- assert_equal("", markdown(""))
- end
-
- def test_markdown_should_sanitize_unsafe_input
- assert_equal("<p>This is worded <strong>strongly</strong></p>", markdown("This is worded <strong>strongly</strong><script>code!</script>"))
- end
-
- def test_markdown_should_not_sanitize_input_if_safe_option
- assert_equal("<p>This is worded <strong>strongly</strong><script>code!</script></p>", markdown("This is worded <strong>strongly</strong><script>code!</script>", :safe))
- end
-
- def test_markdown_should_not_sanitize_safe_input
- assert_equal("<p>This is worded <strong>strongly</strong><script>code!</script></p>", markdown("This is worded <strong>strongly</strong><script>code!</script>".html_safe))
- end
-
- def test_markdown_with_hard_breaks
- assert_equal("<p>This is one scary world.</p>\n\n<p>True.</p>", markdown("This is one scary world.\n\nTrue."))
- end
- end
end

16 comments on commit 0919c0d

@nicolasblanco
Contributor

Extracted in a plugin?

@josevalim
Member

Plugin extraction is in the to-do-list. If you want to go ahead and do it, we appreciate!

@rohit
Contributor
rohit commented on 0919c0d Jun 9, 2010

MY PRECIOUSSS!!!

@josevalim
Member

LOL

@sikachu
Member
sikachu commented on 0919c0d Jun 9, 2010

I was complained with myself about 'Why do I need RedCloth and BlueCloth', and today you remove 'em both. Thanks a lot man!

@reu
Contributor
reu commented on 0919c0d Jun 9, 2010

BTW Josevalim, I just extract them, if you want just clone the repo

http://github.com/reu/markup_helpers

@dtrasbo
Contributor
dtrasbo commented on 0919c0d Jun 9, 2010

José,

As a matter of fact I've extracted the helpers into a gem/plugin too. Didn't know someone else was working on it as well.

http://github.com/dtrasbo/formatize

reu: I'm not making this into a competition or anything - I just want to point out that Formatize has a thorough readme, plus it's been released as a gem. (It can also be installed as a plugin).

@jeremy
Member
jeremy commented on 0919c0d Jun 9, 2010

Thanks David and Rodrigo!

@reu
Contributor
reu commented on 0919c0d Jun 9, 2010

Hey dtrasbo, no problems at all. I didn't know you were working on that too, and clearly your version of the extraction is way better.

@dtrasbo
Contributor
dtrasbo commented on 0919c0d Jun 9, 2010

reu: Thanks! I'm glad you think that way. :)

@spastorino
Member

I already did the plugin when i remove this code but of course as it was said on RailsIgnite we can have text_helper, text_helper_fu and sexy_text_helper plugins :P. I need a rails/text_helper repo created though.

@dtrasbo
Contributor
dtrasbo commented on 0919c0d Jun 9, 2010

spastorino,

Well, in that case it might have been helpful to mention it in the commit message.

I spent quite a bit of time doing that extraction and I'm sure reu did too.

@spastorino
Member

go ahead dtrasbo is yours ;)

@rohit
Contributor
rohit commented on 0919c0d Jun 10, 2010

What? :O
Next time I don't sleep on an idea! I thought I would extract those helpers into a plugin in the morning. Wake up and find everybody has done it! :P

@rohit
Contributor
rohit commented on 0919c0d Jun 10, 2010

I wrote one too. :)
More for learning sake though, not to compete with David's formatize. Also I've used RDiscount instead of BlueCloth and made some minor internal tweaks. http://github.com/rohit/prarupa
P.S It's my 1st plugin/gem so things may explode. :)

@arnekolja

Why weren't this one put into the release notes for Rails 3.0.0 final? It cost me and a co-worker a lot of searching for the reason why this one is gone without any note about it. Especially because it was still there in the betas. It's a good step to modularize it that way, but I think there might be many people who run into errors because of not speaking it out loud.

Please sign in to comment.