Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

do not assume code blocks have blank lines around, also nontextile ->…

… notextile
  • Loading branch information...
commit eb472d6d21a7f29d381e5df0c8d5163d5da778c6 1 parent f6fbdf3
@fxn fxn authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 railties/guides/rails_guides/generator.rb
View
10 railties/guides/rails_guides/generator.rb
@@ -109,8 +109,8 @@ def set_index(body, view)
end
def textile(body)
- # If the issue with nontextile is fixed just remove the wrapper.
- with_workaround_for_nontextile(body) do |body|
+ # If the issue with notextile is fixed just remove the wrapper.
+ with_workaround_for_notextile(body) do |body|
t = RedCloth.new(body)
t.hard_breaks = false
t.to_html(:notestuff, :plusplus, :code, :tip)
@@ -120,18 +120,18 @@ def textile(body)
# For some reason the notextile tag does not always turn off textile. See
# LH ticket of the security guide (#7). As a temporary workaround we deal
# with code blocks by hand.
- def with_workaround_for_nontextile(body)
+ 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>}
- "dirty_workaround_for_nontextile_#{code_blocks.size - 1}"
+ "\ndirty_workaround_for_notextile_#{code_blocks.size - 1}\n"
end
body = yield body
- body.gsub(%r{<p>dirty_workaround_for_nontextile_(\d+)</p>}) do |_|
+ body.gsub(%r{<p>dirty_workaround_for_notextile_(\d+)</p>}) do |_|
code_blocks[$1.to_i]
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.