aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/rails_guides
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-10-24 00:35:47 +0200
committerXavier Noria <fxn@hashref.com>2010-10-24 00:35:47 +0200
commit5f5496c7f3a9351d3e6caef727654fa2b4bdb311 (patch)
tree84cf3d77f0e97dbf05886258f4854f88422f83e5 /railties/guides/rails_guides
parenta3f96f16f48dcdb8364d941f760c159ee136d36e (diff)
downloadrails-5f5496c7f3a9351d3e6caef727654fa2b4bdb311.tar.gz
rails-5f5496c7f3a9351d3e6caef727654fa2b4bdb311.tar.bz2
rails-5f5496c7f3a9351d3e6caef727654fa2b4bdb311.zip
switches guides code syntax highlighting to the better SyntaxHighlighter, I did my best with the theme, I swear
Diffstat (limited to 'railties/guides/rails_guides')
-rw-r--r--railties/guides/rails_guides/generator.rb24
1 files changed, 21 insertions, 3 deletions
diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb
index eaa9d79ce8..22d402ad21 100644
--- a/railties/guides/rails_guides/generator.rb
+++ b/railties/guides/rails_guides/generator.rb
@@ -207,10 +207,28 @@ module RailsGuides
# with code blocks by hand.
def with_workaround_for_notextile(body)
code_blocks = []
+
body.gsub!(%r{<(yaml|shell|ruby|erb|html|sql|plain)>(.*?)</\1>}m) do |m|
- es = ERB::Util.h($2)
- css_class = ['erb', 'shell'].include?($1) ? 'html' : $1
- code_blocks << %{<div class="code_container"><code class="#{css_class}">#{es}</code></div>}
+ brush = case $1
+ when 'ruby', 'sql', 'plain'
+ $1
+ when 'erb'
+ 'ruby; html-script: true'
+ when 'html'
+ 'xml' # html is understood, but there are .xml rules in the CSS
+ else
+ 'plain'
+ end
+
+ code_blocks.push(<<HTML)
+<notextile>
+<div class="code_container">
+<pre class="brush: #{brush}; gutter: false">
+#{ERB::Util.h($2).chomp}
+</pre>
+</div>
+</notextile>
+HTML
"\ndirty_workaround_for_notextile_#{code_blocks.size - 1}\n"
end