mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Fixed RedCloth and BlueCloth shouldn't preload. Instead just assume that they're available if you want to use textilize and markdown and let autoload require them [DHH]
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
*2.3.0/3.0*
|
||||
|
||||
* Fixed RedCloth and BlueCloth shouldn't preload. Instead just assume that they're available if you want to use textilize and markdown and let autoload require them [DHH]
|
||||
|
||||
|
||||
*2.2.1 [RC2] (November 14th, 2008)*
|
||||
|
||||
* Restore backwards compatible functionality for setting relative_url_root. Include deprecation
|
||||
|
||||
@@ -226,91 +226,79 @@ module ActionView
|
||||
end * "\n"
|
||||
end
|
||||
|
||||
begin
|
||||
require_library_or_gem "redcloth" unless Object.const_defined?(:RedCloth)
|
||||
|
||||
# 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://whytheluckystiff.net/ruby/redcloth/]
|
||||
# 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>"
|
||||
def textilize(text)
|
||||
if text.blank?
|
||||
""
|
||||
else
|
||||
textilized = RedCloth.new(text, [ :hard_breaks ])
|
||||
textilized.hard_breaks = true if textilized.respond_to?(:hard_breaks=)
|
||||
textilized.to_html
|
||||
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://whytheluckystiff.net/ruby/redcloth/]
|
||||
# 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>"
|
||||
def textilize(text)
|
||||
if text.blank?
|
||||
""
|
||||
else
|
||||
textilized = RedCloth.new(text, [ :hard_breaks ])
|
||||
textilized.hard_breaks = true if textilized.respond_to?(:hard_breaks=)
|
||||
textilized.to_html
|
||||
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://whytheluckystiff.net/ruby/redcloth/]
|
||||
# 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)
|
||||
textiled = textilize(text)
|
||||
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
|
||||
rescue LoadError
|
||||
# We can't really help what's not there
|
||||
end
|
||||
|
||||
begin
|
||||
require_library_or_gem "bluecloth" unless Object.const_defined?(:BlueCloth)
|
||||
# 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 requires RedCloth[http://whytheluckystiff.net/ruby/redcloth/]
|
||||
# to be 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)
|
||||
textiled = textilize(text)
|
||||
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 is only available if BlueCloth[http://www.deveiate.org/projects/BlueCloth]
|
||||
# is 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('')
|
||||
# # => '<p><img src="http://rubyonrails.com/images/rails.png" alt="The ROR logo" title="Ruby on Rails" /></p>'
|
||||
def markdown(text)
|
||||
text.blank? ? "" : BlueCloth.new(text).to_html
|
||||
end
|
||||
rescue LoadError
|
||||
# We can't really help what's not there
|
||||
# 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('')
|
||||
# # => '<p><img src="http://rubyonrails.com/images/rails.png" alt="The ROR logo" title="Ruby on Rails" /></p>'
|
||||
def markdown(text)
|
||||
text.blank? ? "" : BlueCloth.new(text).to_html
|
||||
end
|
||||
|
||||
# Returns +text+ transformed into HTML using simple formatting rules.
|
||||
|
||||
Reference in New Issue
Block a user