instiki/vendor/rails/railties/guides/rails_guides/textile_extensions.rb
Jacques Distler 133c21b801 Bugfixes and Rails Edge
Update to Rails 2.3.1.
  (Actually, not quite. Doesn't look like 2.3.1 will be released
   today, but I REALLY want to push these bugfixes out.)
Removed bundled Rack (Rails 2.3.1 comes bundled with Rack 1.0).
Add
     config.action_view.cache_template_loading = true
  to production environment.
Fix FastCGI bug (http://rubyforge.org/tracker/index.php?func=detail&aid=24191&group_id=186&atid=783).
Fix WikiWords bug (http://rubyforge.org/pipermail/instiki-users/2009-February/001181.html).
2009-02-27 19:23:00 -06:00

42 lines
1 KiB
Ruby

module RailsGuides
module TextileExtensions
def notestuff(body)
body.gsub!(/^(IMPORTANT|CAUTION|WARNING|NOTE|INFO)(?:\.|\:)(.*)$/) do |m|
css_class = $1.downcase
css_class = 'warning' if ['caution', 'important'].include?(css_class)
result = "<div class='#{css_class}'><p>"
result << $2.strip
result << '</p></div>'
result
end
end
def tip(body)
body.gsub!(/^(TIP)\:(.*)$/) do |m|
result = "<div class='info'><p>"
result << $2.strip
result << '</p></div>'
result
end
end
def plusplus(body)
body.gsub!(/\+(.*?)\+/) do |m|
"<notextile><tt>#{$1}</tt></notextile>"
end
# The real plus sign
body.gsub!('<plus>', '+')
end
def code(body)
body.gsub!(/\<(yaml|shell|ruby|erb|html|sql)\>(.*?)\<\/\1\>/m) do |m|
es = ERB::Util.h($2)
css_class = ['erb', 'shell'].include?($1) ? 'html' : $1
"<notextile><code class='#{css_class}'>#{es}\n</code></notextile>"
end
end
end
end