aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/rails_guides/textile_extensions.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-02-04 01:44:58 +0000
committerPratik Naik <pratiknaik@gmail.com>2009-02-04 01:44:58 +0000
commit03bb1ebec513de779908af110c46e16b9c882673 (patch)
tree4df5643c61501de1b8e4101746e324a183042262 /railties/guides/rails_guides/textile_extensions.rb
parente4094e23f9e3740599e9eaac527fbef86ff4b4c4 (diff)
downloadrails-03bb1ebec513de779908af110c46e16b9c882673.tar.gz
rails-03bb1ebec513de779908af110c46e16b9c882673.tar.bz2
rails-03bb1ebec513de779908af110c46e16b9c882673.zip
Convert the guides from asciidoc to textile and integrate with the new design.
If you're a guide writer and want to generate the guides, Run : ruby railties/guides/rails_guides.rb And guides HTML will get generated inside railties/guides/output directory.
Diffstat (limited to 'railties/guides/rails_guides/textile_extensions.rb')
-rw-r--r--railties/guides/rails_guides/textile_extensions.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/railties/guides/rails_guides/textile_extensions.rb b/railties/guides/rails_guides/textile_extensions.rb
new file mode 100644
index 0000000000..a7fc5ba49c
--- /dev/null
+++ b/railties/guides/rails_guides/textile_extensions.rb
@@ -0,0 +1,38 @@
+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
+ 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