diff options
Diffstat (limited to 'railties/guides/rails_guides/generator.rb')
-rw-r--r-- | railties/guides/rails_guides/generator.rb | 24 |
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..0a2170a09e 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; toolbar: false"> +#{ERB::Util.h($2).strip} +</pre> +</div> +</notextile> +HTML "\ndirty_workaround_for_notextile_#{code_blocks.size - 1}\n" end |