Skip to content
This repository
Browse code

Removed textilize, textilize_without_paragraph and markdown helpers

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit 0919c0dbca3df02f5cfff7dde4f61b85ef16d886 1 parent f48aa14
Santiago Pastorino authored June 09, 2010 josevalim committed June 09, 2010
4  Gemfile
@@ -44,10 +44,6 @@ elsif RUBY_ENGINE == "jruby"
44 44
   end
45 45
 end
46 46
 
47  
-# AP
48  
-gem "RedCloth", ">= 4.2.2"
49  
-gem "bluecloth", ">= 2.0.7"
50  
-
51 47
 group :documentation do
52 48
   gem 'rdoc', '2.1'
53 49
 end
2  actionpack/CHANGELOG
... ...
@@ -1,3 +1,5 @@
  1
+* Removed textilize, textilize_without_paragraph and markdown helpers. [Santiago Pastorino]
  2
+
1 3
 *Rails 3.0.0 [beta 4] (June 8th, 2010)*
2 4
 
3 5
 * Remove middleware laziness [José Valim]
83  actionpack/lib/action_view/helpers/text_helper.rb
@@ -220,89 +220,6 @@ def word_wrap(text, *args)
220 220
         end * "\n"
221 221
       end
222 222
 
223  
-      # Returns the text with all the Textile[http://www.textism.com/tools/textile] codes turned into HTML tags.
224  
-      #
225  
-      # You can learn more about Textile's syntax at its website[http://www.textism.com/tools/textile].
226  
-      # <i>This method is only available if RedCloth[http://redcloth.org/] is available</i>.
227  
-      #
228  
-      # ==== Examples
229  
-      #   textilize("*This is Textile!*  Rejoice!")
230  
-      #   # => "<p><strong>This is Textile!</strong>  Rejoice!</p>"
231  
-      #
232  
-      #   textilize("I _love_ ROR(Ruby on Rails)!")
233  
-      #   # => "<p>I <em>love</em> <acronym title="Ruby on Rails">ROR</acronym>!</p>"
234  
-      #
235  
-      #   textilize("h2. Textile makes markup -easy- simple!")
236  
-      #   # => "<h2>Textile makes markup <del>easy</del> simple!</h2>"
237  
-      #
238  
-      #   textilize("Visit the Rails website "here":http://www.rubyonrails.org/.)
239  
-      #   # => "<p>Visit the Rails website <a href="http://www.rubyonrails.org/">here</a>.</p>"
240  
-      #
241  
-      #   textilize("This is worded <strong>strongly</strong>")
242  
-      #   # => "<p>This is worded <strong>strongly</strong></p>"
243  
-      #
244  
-      #   textilize("This is worded <strong>strongly</strong>", :filter_html)
245  
-      #   # => "<p>This is worded &lt;strong&gt;strongly&lt;/strong&gt;</p>"
246  
-      #
247  
-      def textilize(text, *options)
248  
-        options ||= [:hard_breaks]
249  
-        text = sanitize(text) unless text.html_safe? || options.delete(:safe)
250  
-
251  
-        if text.blank?
252  
-          ""
253  
-        else
254  
-          textilized = RedCloth.new(text, options)
255  
-          textilized.to_html
256  
-        end.html_safe
257  
-      end
258  
-
259  
-      # Returns the text with all the Textile codes turned into HTML tags,
260  
-      # but without the bounding <p> tag that RedCloth adds.
261  
-      #
262  
-      # You can learn more about Textile's syntax at its website[http://www.textism.com/tools/textile].
263  
-      # <i>This method is only available if RedCloth[http://redcloth.org/] is available</i>.
264  
-      #
265  
-      # ==== Examples
266  
-      #   textilize_without_paragraph("*This is Textile!*  Rejoice!")
267  
-      #   # => "<strong>This is Textile!</strong>  Rejoice!"
268  
-      #
269  
-      #   textilize_without_paragraph("I _love_ ROR(Ruby on Rails)!")
270  
-      #   # => "I <em>love</em> <acronym title="Ruby on Rails">ROR</acronym>!"
271  
-      #
272  
-      #   textilize_without_paragraph("h2. Textile makes markup -easy- simple!")
273  
-      #   # => "<h2>Textile makes markup <del>easy</del> simple!</h2>"
274  
-      #
275  
-      #   textilize_without_paragraph("Visit the Rails website "here":http://www.rubyonrails.org/.)
276  
-      #   # => "Visit the Rails website <a href="http://www.rubyonrails.org/">here</a>."
277  
-      def textilize_without_paragraph(text, *options)
278  
-        textiled = textilize(text, *options)
279  
-        if textiled[0..2] == "<p>" then textiled = textiled[3..-1] end
280  
-        if textiled[-4..-1] == "</p>" then textiled = textiled[0..-5] end
281  
-        return textiled
282  
-      end
283  
-
284  
-      # Returns the text with all the Markdown codes turned into HTML tags.
285  
-      # <i>This method requires BlueCloth[http://www.deveiate.org/projects/BlueCloth]
286  
-      # to be available</i>.
287  
-      #
288  
-      # ==== Examples
289  
-      #   markdown("We are using __Markdown__ now!")
290  
-      #   # => "<p>We are using <strong>Markdown</strong> now!</p>"
291  
-      #
292  
-      #   markdown("We like to _write_ `code`, not just _read_ it!")
293  
-      #   # => "<p>We like to <em>write</em> <code>code</code>, not just <em>read</em> it!</p>"
294  
-      #
295  
-      #   markdown("The [Markdown website](http://daringfireball.net/projects/markdown/) has more information.")
296  
-      #   # => "<p>The <a href="http://daringfireball.net/projects/markdown/">Markdown website</a>
297  
-      #   #     has more information.</p>"
298  
-      #
299  
-      #   markdown('![The ROR logo](http://rubyonrails.com/images/rails.png "Ruby on Rails")')
300  
-      #   # => '<p><img src="http://rubyonrails.com/images/rails.png" alt="The ROR logo" title="Ruby on Rails" /></p>'
301  
-      def markdown(text, *options)
302  
-        text = sanitize(text) unless text.html_safe? || options.delete(:safe)
303  
-        (text.blank? ? "" : BlueCloth.new(text).to_html).html_safe
304  
-      end
305  
-
306 223
       # Returns +text+ transformed into HTML using simple formatting rules.
307 224
       # Two or more consecutive newlines(<tt>\n\n</tt>) are considered as a
308 225
       # paragraph and wrapped in <tt><p></tt> tags. One newline (<tt>\n</tt>) is
108  actionpack/test/template/text_helper_test.rb
... ...
@@ -1,17 +1,6 @@
1 1
 # encoding: us-ascii
2 2
 require 'abstract_unit'
3 3
 require 'testing_sandbox'
4  
-begin
5  
-  require 'redcloth'
6  
-rescue LoadError
7  
-  $stderr.puts "Skipping textilize tests. `gem install RedCloth` to enable."
8  
-end
9  
-
10  
-begin
11  
-  require 'bluecloth'
12  
-rescue LoadError
13  
-  $stderr.puts "Skipping markdown tests. 'gem install bluecloth' to enable."
14  
-end
15 4
 
16 5
 class TextHelperTest < ActionView::TestCase
17 6
   tests ActionView::Helpers::TextHelper
@@ -665,101 +654,4 @@ def test_cycle_no_instance_variable_clashes
665 654
     assert_equal("red", cycle("red", "blue"))
666 655
     assert_equal(%w{Specialized Fuji Giant}, @cycles)
667 656
   end
668  
-
669  
-  # TODO test textilize_without_paragraph and markdown
670  
-  if defined? RedCloth
671  
-    def test_textilize_should_be_html_safe
672  
-      assert textilize("*This is Textile!*  Rejoice!").html_safe?
673  
-    end
674  
-
675  
-    def test_textilize
676  
-      assert_equal("<p><strong>This is Textile!</strong>  Rejoice!</p>", textilize("*This is Textile!*  Rejoice!"))
677  
-    end
678  
-
679  
-    def test_textilize_with_blank
680  
-      assert_equal("", textilize(""))
681  
-    end
682  
-
683  
-    def test_textilize_with_options
684  
-      assert_equal("<p>This is worded &lt;strong&gt;strongly&lt;/strong&gt;</p>", textilize("This is worded <strong>strongly</strong>", :filter_html))
685  
-    end
686  
-
687  
-    def test_textilize_should_sanitize_unsafe_input
688  
-      assert_equal("<p>This is worded <strong>strongly</strong></p>", textilize("This is worded <strong>strongly</strong><script>code!</script>"))
689  
-    end
690  
-
691  
-    def test_textilize_should_not_sanitize_input_if_safe_option
692  
-      assert_equal("<p>This is worded <strong>strongly</strong><script>code!</script></p>", textilize("This is worded <strong>strongly</strong><script>code!</script>", :safe))
693  
-    end
694  
-
695  
-    def test_textilize_should_not_sanitize_safe_input
696  
-      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))
697  
-    end
698  
-
699  
-    def test_textilize_with_hard_breaks
700  
-      assert_equal("<p>This is one scary world.<br />\n True.</p>", textilize("This is one scary world.\n True."))
701  
-    end
702  
-
703  
-    def test_textilize_without_paragraph_should_be_html_safe
704  
-      textilize_without_paragraph("*This is Textile!*  Rejoice!").html_safe?
705  
-    end
706  
-
707  
-    def test_textilize_without_paragraph
708  
-      assert_equal("<strong>This is Textile!</strong>  Rejoice!", textilize_without_paragraph("*This is Textile!*  Rejoice!"))
709  
-    end
710  
-
711  
-    def test_textilize_without_paragraph_with_blank
712  
-      assert_equal("", textilize_without_paragraph(""))
713  
-    end
714  
-
715  
-    def test_textilize_without_paragraph_with_options
716  
-      assert_equal("This is worded &lt;strong&gt;strongly&lt;/strong&gt;", textilize_without_paragraph("This is worded <strong>strongly</strong>", :filter_html))
717  
-    end
718  
-
719  
-    def test_textilize_without_paragraph_should_sanitize_unsafe_input
720  
-      assert_equal("This is worded <strong>strongly</strong>", textilize_without_paragraph("This is worded <strong>strongly</strong><script>code!</script>"))
721  
-    end
722  
-
723  
-    def test_textilize_without_paragraph_should_not_sanitize_input_if_safe_option
724  
-      assert_equal("This is worded <strong>strongly</strong><script>code!</script>", textilize_without_paragraph("This is worded <strong>strongly</strong><script>code!</script>", :safe))
725  
-    end
726  
-
727  
-    def test_textilize_without_paragraph_should_not_sanitize_safe_input
728  
-      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))
729  
-    end
730  
-
731  
-    def test_textilize_without_paragraph_with_hard_breaks
732  
-      assert_equal("This is one scary world.<br />\n True.", textilize_without_paragraph("This is one scary world.\n True."))
733  
-    end
734  
-  end
735  
-
736  
-  if defined? BlueCloth
737  
-    def test_markdown_should_be_html_safe
738  
-      assert markdown("We are using __Markdown__ now!").html_safe?
739  
-    end
740  
-
741  
-    def test_markdown
742  
-      assert_equal("<p>We are using <strong>Markdown</strong> now!</p>", markdown("We are using __Markdown__ now!"))
743  
-    end
744  
-
745  
-    def test_markdown_with_blank
746  
-      assert_equal("", markdown(""))
747  
-    end
748  
-
749  
-    def test_markdown_should_sanitize_unsafe_input
750  
-      assert_equal("<p>This is worded <strong>strongly</strong></p>", markdown("This is worded <strong>strongly</strong><script>code!</script>"))
751  
-    end
752  
-
753  
-    def test_markdown_should_not_sanitize_input_if_safe_option
754  
-      assert_equal("<p>This is worded <strong>strongly</strong><script>code!</script></p>", markdown("This is worded <strong>strongly</strong><script>code!</script>", :safe))
755  
-    end
756  
-
757  
-    def test_markdown_should_not_sanitize_safe_input
758  
-      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))
759  
-    end
760  
-
761  
-    def test_markdown_with_hard_breaks
762  
-      assert_equal("<p>This is one scary world.</p>\n\n<p>True.</p>", markdown("This is one scary world.\n\nTrue."))
763  
-    end
764  
-  end
765 657
 end

16 notes on commit 0919c0d

Nicolas Blanco

Extracted in a plugin?

José Valim
Owner

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

Rohit Arondekar
rohit commented on 0919c0d June 09, 2010

MY PRECIOUSSS!!!

José Valim
Owner

LOL

Prem Sichanugrist
Collaborator

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

Rodrigo Navarro
reu commented on 0919c0d June 09, 2010

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

http://github.com/reu/markup_helpers

David Trasbo

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 Kemper
Owner

Thanks David and Rodrigo!

Rodrigo Navarro
reu commented on 0919c0d June 09, 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.

David Trasbo

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

Santiago Pastorino
Owner

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.

David Trasbo

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.

Santiago Pastorino
Owner

go ahead dtrasbo is yours ;)

Rohit Arondekar
rohit commented on 0919c0d June 09, 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 Arondekar
rohit commented on 0919c0d June 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. :)

Arne-Kolja Bachstein

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.
Something went wrong with that request. Please try again.