From 18eb80ccc7e932f9a6c00462ceaeea648631b120 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Mon, 16 Mar 2009 11:28:36 +0000 Subject: Merge docrails --- railties/guides/rails_guides/generator.rb | 36 +++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'railties/guides/rails_guides/generator.rb') diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb index 18fdb81810..8e69af5bde 100644 --- a/railties/guides/rails_guides/generator.rb +++ b/railties/guides/rails_guides/generator.rb @@ -109,8 +109,8 @@ module RailsGuides 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,33 +120,51 @@ module RailsGuides # 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)>(.*?)}m) do |m| es = ERB::Util.h($2) css_class = ['erb', 'shell'].include?($1) ? 'html' : $1 code_blocks << %{
#{es}
} - "dirty_workaround_for_nontextile_#{code_blocks.size - 1}" + "\ndirty_workaround_for_notextile_#{code_blocks.size - 1}\n" end body = yield body - body.gsub(%r{

dirty_workaround_for_nontextile_(\d+)

}) do |_| + body.gsub(%r{

dirty_workaround_for_notextile_(\d+)

}) do |_| code_blocks[$1.to_i] end end def warn_about_broken_links(html) + anchors = extract_anchors(html) + check_fragment_identifiers(html, anchors) + end + + def extract_anchors(html) # Textile generates headers with IDs computed from titles. - anchors = Set.new(html.scan(/ Levenshtein.distance(fragment_identifier, b) + } + puts "*** BROKEN LINK: ##{fragment_identifier}, perhaps you meant ##{guess}." end end end -- cgit v1.2.3