aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/rails_guides/textile_extensions.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2011-08-07 16:20:31 -0700
committerXavier Noria <fxn@hashref.com>2011-08-07 16:20:51 -0700
commite746980507ed48e30ab35daf587bf9863d5b9261 (patch)
treeef7585678640be1a1a69a04576af6ab43345eb94 /railties/guides/rails_guides/textile_extensions.rb
parente06db7276ca6acfb8218fdf8a6c8d9532360a1ae (diff)
downloadrails-e746980507ed48e30ab35daf587bf9863d5b9261.tar.gz
rails-e746980507ed48e30ab35daf587bf9863d5b9261.tar.bz2
rails-e746980507ed48e30ab35daf587bf9863d5b9261.zip
guides generation: apparently this workaround for RedCloth is not needed anymore
Diffstat (limited to 'railties/guides/rails_guides/textile_extensions.rb')
-rw-r--r--railties/guides/rails_guides/textile_extensions.rb25
1 files changed, 22 insertions, 3 deletions
diff --git a/railties/guides/rails_guides/textile_extensions.rb b/railties/guides/rails_guides/textile_extensions.rb
index b3e0e32357..4677fae504 100644
--- a/railties/guides/rails_guides/textile_extensions.rb
+++ b/railties/guides/rails_guides/textile_extensions.rb
@@ -33,11 +33,30 @@ module RailsGuides
body.gsub!('<plus>', '+')
end
+ def brush_for(code_type)
+ case code_type
+ when 'ruby', 'sql', 'plain'
+ code_type
+ when 'erb'
+ 'ruby; html-script: true'
+ when 'html'
+ 'xml' # html is understood, but there are .xml rules in the CSS
+ else
+ 'plain'
+ end
+ end
+
def code(body)
body.gsub!(%r{<(yaml|shell|ruby|erb|html|sql|plain)>(.*?)</\1>}m) do |m|
- es = ERB::Util.h($2)
- css_class = $1.in?(['erb', 'shell']) ? 'html' : $1
- %{<notextile><div class="code_container"><code class="#{css_class}">#{es}</code></div></notextile>}
+ <<HTML
+<notextile>
+<div class="code_container">
+<pre class="brush: #{brush_for($1)}; gutter: false; toolbar: false">
+#{ERB::Util.h($2).strip}
+</pre>
+</div>
+</notextile>
+HTML
end
end
end