提交 0919c0db 编写于 作者: S Santiago Pastorino 提交者: José Valim

Removed textilize, textilize_without_paragraph and markdown helpers

Signed-off-by: NJosé Valim <jose.valim@gmail.com>
上级 f48aa14b
......@@ -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
......
* 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
......
# 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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册