Flowdock
method

warn_about_broken_links

Importance_0
v2.3.2 - Show latest stable - 0 notes - Class: RailsGuides::Generator
warn_about_broken_links(html) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File railties/guides/rails_guides/generator.rb, line 140
    def warn_about_broken_links(html)
      # Textile generates headers with IDs computed from titles.
      anchors  = Set.new(html.scan(/<h\d\s+id="([^"]+)/).flatten)
      # Also, footnotes are rendered as paragraphs this way.
      anchors += Set.new(html.scan(/<p\s+class="footnote"\s+id="([^"]+)/).flatten)
      
      # Check fragment identifiers.
      html.scan(/<a\s+href="#([^"]+)/).flatten.each do |fragment_identifier|
        next if fragment_identifier == 'mainCol' # in layout, jumps to some DIV
        unless anchors.member?(fragment_identifier)
          puts "BROKEN LINK: ##{fragment_identifier}"
        end
      end
    end
Register or log in to add new notes.